Skip to main content

Posts

Solution of More than one file was found with OS independent path AndroidManifest.xml

After adding some jar or third party libraries sometime we face this type of problem during gradle build or at runtime .it might be because of in the mergeDebugJavaResource gradle task and on error message about multiple Android Manifests .
We can assume that the problem is that there are several manifests(for example one for debug and one for production) and there are no proper manifest merging rules.
sometimes it will resolve by Invalid Caches and Restart the Android Studio or by cleaning and rebuild project.
But if this technique does not work than there are some solutions for this:

Solution 1:
downgrading your gradle plugin version from high version to low version like converting classpath 'com.android.tools.build:gradle:3.5.1' to  classpath 'com.android.tools.build:gradle:3.4.0'
if this solution not work here is another solution.

Solution 2:
in your app level gradle add these line of code 
android { .... packagingOptions {
exclude 'AndroidManifest.xml'
}
..... }
hope this sol…
Recent posts

How to add Vibrate or Shake effect to any View

Sometimes we have to apply Shake or Vibrate effect to a view like text view or any other view for indicating user that something went wrong or wrong input.To achieve this we have some steps to follow:-

For Vibrate
Step 1: Create the object for the Vibrator class private Vibrator vibrateObject;
Step 2 : Block of code for vibrate the device for 300 millisecond
vibrateObject = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 300 milliseconds vibrateObject.vibrate(300);
Step 3: Add permission in Manifest.xml
<uses-permission android:name="android.permission.VIBRATE" />
Shake The View Or TextStep 1: Create shake_effect.xml in anim folder  <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromXDelta="0" android:interpolator="@anim/cycle_inter2" android:toXDelta=&q…

How to Hide or Show Toolbar While Scrolling

Sometimes we have requirement for hiding the toolbar when some list is scroll .In this post we will learn how to hide when scroll down the list and show when scroll upside in Android Application.For this we have to follow some steps :-
Step 1: Create a ToolBar separately for use it in an entire application with name toolbar.xml <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:titleTextColor="#FFFFFF" app:layout_scrollFlags="scroll|enterAlways" /> set this flag to toolBarapp:layout_scrollFlags="scroll|enterAlways"app:layout_scrollFlags attri…

All about Android extension libraries (AndroidX)

Nowadays we commonly get this type of error in gradle when we use third party library :

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-rc02] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.0-rc01] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
we get this types of error when library is updated and providing use of AndroidX but we are using old one.

To solve this error we have to migrate our project into AndroidX .if you still don't want to use AndroidX use have to do lots of stuff and also downgrade your googlePlayServices and firebase version.

So in this Article we will discuss about what is AndroidX, How to Migrate to AndroidX and when to use …

Connection type HTTP not supported in Android Pie(9)

Sometimes we face the error that same application which support http not working in some mobile devices specially in android pie and above devices and even some websites not showing in WebView with http connection type url . The error is something like this:

Exception: IOException java.io.IOException: Cleartext HTTP traffic to * not permitted

and same error in Web View like:


so in this post we will learn about how to solve this problem and make our app support for all devices. So lets start -

As per the Android Documentation 

From Android 9 Pie now, requests without encryption will never work. And by default, the System will expect you to use TLS by default.Starting with Android 9 (API level 28), cleartext support is disabled by default.Android 9 adds built-in support for DNS over TLS, automatically upgrading DNS queries to TLS if a network's DNS server supports it.
so from android pie we can say that the default http is not supported and by default connection type supported is http…

How to Create Image Slider with Page Indicator

Image slider are used in almost every Android Application .In this post we will Learn about Creating Image Slider with page Indicator.So lets start with Coding part:-


First of all we need to add this library in our build.gradle file

compile 'com.squareup.picasso:picasso:2.3.3'

Step 1:

activity_main.xml

<RelativeLayout android:layout_width="match_parent" android:layout_height="200dp"> <android.support.v4.view.ViewPager android:id="@+id/vp_slider" android:layout_width="match_parent" android:layout_height="match_parent" /> <LinearLayout android:id="@+id/ll_dots" android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentBottom="true" android:layout_marginBottom="20dp" android:gravity="center" android:orientation="horizontal"></LinearLayout> </RelativeLayout>…

How to Download Apk file from Url and Install Programmatically

In this post we learn about download apk file from server or website and then install it Programmatically in Phone.

Sometimes we have to download external apk file from server and then install if downloading successfully finished.For this we use AsyncTask class  for background process. So here is Code Snippet for this task.Lets Start :-


Before this we have to add these Permissions in Manifest.xml file :

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
DownloadNewVersion.java

class DownloadNewVersion extends AsyncTask<String,Integer,Boolean> { @Override protected void onPreExecute() { super.onPreExecute(); bar = new ProgressDialog(getActivity()); bar.setCancelable(false); bar.setMessage("Downloading...&qu…

How to Take Screenshot of Current activity and Share Options

Sometimes we have to share the Report or Final receipt Screen  from the Current Application  .In this scenario we take screenshot of Current activity and then share this as image file using sharing Options . So lets move to the Coding Part without wasting time .


1: public class MainActivity extends AppCompatActivity { 2: File imagePath; 3: @Override 4: protected void onCreate(Bundle savedInstanceState) { 5: super.onCreate(savedInstanceState); 6: setContentView(R.layout.activity_main); 7: getSupportActionBar().setDisplayHomeAsUpEnabled(true); 8: ImageView imageView=(ImageView)findViewById(R.id.share); 9: imageView.setOnClickListener(new View.OnClickListener() { 10: @Override 11: public void onClick(View v) { 12: Bitmap bitmap = takeScreenshot(); 13: saveBitmap(bitmap); 14: shareIt(); 15: } 16: }); 17: } 18: public Bitmap takeScreenshot() { 19: View root…

Android Multi Select Dialog Box

Making Multi Select Dialog box is Pretty Simple and it can be achieved by few lines of coding . So lets move to the Coding Part .

Steps:

1.    Create an String Array named "items"
2.   Initialize ArrayList itemsSelected and add if item is selected or remove if not selected .
3.   Get values of selected Items in itemsSelected and use it where ever you want .



1: import android.app.AlertDialog; 2: import android.app.Dialog; 3: import android.content.DialogInterface; 4: import android.os.Bundle; 5: import android.support.v7.app.ActionBarActivity; 6: import java.util.ArrayList; 7: public class MainActivity extends ActionBarActivity { 8: @Override 9: protected void onCreate(Bundle savedInstanceState) { 10: super.onCreate(savedInstanceState); 11: setContentView(R.layout.activity_main); 12: Dialog dialog; 13: final String[] items = {" C", " JAVA", " Kotlin", " Python", " Objective-C…

How to Find specific App Installed in Mobile or Not

In Android sometimes we have to determine that the Specific app is installed in mobile or Not .So here is Code snippet to find the specific package name application installed or not .


public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Add respective layout setContentView(R.layout.main_activity); // Use package name which we want to check boolean isAppInstalled = appInstalledOrNot("com.check.application"); // App package here if(isAppInstalled) { //This intent will help you to launch if the package is already installed Intent LaunchIntent = getPackageManager() .getLaunchIntentForPackage("com.check.application"); startActivity(LaunchIntent); Log.i("Application is already installed."); } else { // Do whatever we want to do if application n…