Tag Archives: Android studio

[Solved] AndroidStudio package Invalid keystore format Error: Execution failed for task ‘:examplecases:packageRelease’…

Post error information first

Execution failed for task ':examplecases:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > com.android.ide.common.signing.KeytoolException: Failed to read key aaa from store "C:\Users\a\Desktop\NewProject\aaa.jks": Invalid keystore format

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 

 

Solution:

Open file -> settings.

Set the JDK version to 11, repack and solve the problem.

[Solved] Phone Debug Program Error: The application could not be installed: INSTALL_FAILED_TEST_ONLY

1. Error message

17:18	Gradle build finished in 2 s 904 ms

17:18	Failed to commit install session 1905086282 with command cmd package install-commit 1905086282. Error: INSTALL_FAILED_TEST_ONLY

17:18	Error
		Installation did not succeed.
		The application could not be installed: INSTALL_FAILED_TEST_ONLY
		Retry

17:18	Session 'app': Installation did not succeed.
		The application could not be installed: INSTALL_FAILED_TEST_ONLY
		Retry

 

2. Solution

1. Problem analysis

 

When you click to run the debugging program, it will be automatically generated in the application tab of the manifest file

android:testOnly="true"

Some mobile phones do not support the installation of such applications;

 

2. Solution 1

Under menu bar/build:

  • Debug apps compiled with Build APK(s) can run;
  • The debug version of the application compiled with Make Project can be run;
  • Released apps packaged with Generate Signed APK signatures will also work;

 

3. Solution 2

Configure in gradle.properties

android.injected.testOnly=false

JZVideo Error: Attempt to invoke virtual method ‘android.view.Window android.app.Activity.getWindow()’ on a null object reference

1. Error reporting

Attempt to invoke virtual method ‘android.view.Window android.app.Activity.getWindow()’ on a null object reference

2. Cause

VideoAdapter.java file code:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_mainlv,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        // Get the data source of the specified location
        String path = "xxxx";
        holder.jzvdStd.setUp(path,"test",JzvdStd.SCREEN_NORMAL);

        holder.jzvdStd.positionInList = position;

        return convertView;
    }

    class ViewHolder{
        JzvdStd jzvdStd;
        public ViewHolder(View view){
            jzvdStd = view.findViewById(R.id.item_main_jzvd);
        }
    }

Since jzvdStd has released the jzvdStd window when the full screen is cut to a small screen, and the subsequent if (convertView == null) judgment, directly to the else statement, so the window that has been released cannot be obtained by the statement in the else in the window, so the error is reported. (The above is a personal opinion)

3. Solution

Replace the above code with the following code

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;
        if (null == convertView) {
            viewHolder = new ViewHolder();
            LayoutInflater mInflater = LayoutInflater.from(context);
            convertView = mInflater.inflate(R.layout.item_mainlv, null);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.jzvdStd = convertView.findViewById(R.id.item_main_jzvd);


        // Get the data source of the specified location
        String path = "xxx";
        viewHolder.jzvdStd.setUp(path,"test",JzvdStd.SCREEN_NORMAL);

        return convertView;
    }

    class ViewHolder{
        JzvdStd jzvdStd;
    }

[Solved] :app:processDebugResources Android resource linking failed Android resource linking failed

Error Message:

:app:processDebugResources Android resource linking failed Android resource linking failed

Error prompt of Android Studio:

:app:processDebugResources
Android resource linking failed
Android resource linking failed

The Solution is as follows:

Just remove it as the screenshot below:

[Solved] Manifest merger failed with multiple errors, see logs

After upgrading Android Sdk to 33 recently, packing Android generates the following problems:

AndroidManifest.xml Error:
 Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Execution failed for task ':launcher:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs

1. Tried to add android:exported as instructed, but the problem remains. So I used the 2nd solution, drop the sdk version.

2. Drop Android sdk version

1. Set the SDK version of Android project as shown in the following figure:

2. After setting, modify the relevant SDK in all build.gradle configuration files in the project to be consistent with the version number configured in the above figure.

compileSdkVersion 30
buildToolsVersion '30.0.2'
targetSdkVersion 30

[Solved] open failed: ENOENT (No such file or directory)

open failed: ENOENT (No such file or directory)

1. Error description

The following error occurred while writing the file to sdcard:

open failed: ENOENT (No such file or directory)

2. Error analysis

At first, I thought I forgot to add read-write permission, which was checked.

Finally, when I think of android10 onwards, in addition to the dynamic application of permissions, you must add in the Application node of AndroidManifest.xml of the main application.

android:requestLegacyExternalStorage="true"

3. Solution

Add the following codes in the Application node of AndroidManifest.xml of the main application:

android:requestLegacyExternalStorage="true"

 

[Solved] Installation failed due to: ‘INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: Package com.

1. No system signature is added

If you have not added the system signature, find the following codes at the header of the AndroidManifest.xml file and delete it:

android:sharedUserId="android.uid.system"

2. Added system signature

  1. Check whether there is any problem with the system signature itself or the joining method?
  2. If there is no problem with the system signature, there should already be an APK in the system, and the current APK should be added to the system uid. At this time, you should first delete the APK that exists in the system, and then reboot.
adb root
adb uninstall com.xxx.xxxx
adb reboot

[How to Solve] Task :app:compileDebugKotlin FAILED

Question:

After changing the app ID and the module name of the Android project, this problem occurred in the compilation.

Solution:

1. tried to unify kotlin version, Android Studio Tools -> Kotlin -> Configure Kotlin Plugin Updates
Check the current Kotlin version, and find kotlin-version in the project (different projects show different ways, usually in build.gradle), change the Kotlin version of the project to the version on Android Studio, and then recompile, it failed.

2. before reporting this error log, look up, you know the problem, is the program code has reported red place, just a matter of habit, each time the red part of the log down to see, resulting in a delay of a good while.

[Solved] Android12 Download Error: The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Android12 install reports an error the application could not be installed: install_ PARSE_ FAILED_ MANIFEST_ MALFORMED

Solution:

For apps with Android12 as the adaptation platform, all four components that contain an intent-filter need to declare the android:exported attribute, and if the intent-filter contains LAUNCHER, it is best to declare it as android:exported= “true”

For example:

 <activity android:name=".MainActivity"
           android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 </activity>

The four main components that use intent-filter can be viewed through the Merged Manifest in the manifest file

If you still get the error Installation failed due to: ‘-127’, try adding the following parameter to the manifest file

<permission-group android:name="${applicationId}.andpermission" />

 

Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Today adb command to install apk,prompted the following error:.
Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

Solution:
Method 1:
Change android:testOnly=”true” to android:testOnly=”false” in AndroidManifest.xml, or just remove it.
Method 2:
adb push .apk /tmp
adb shell pm install -t /tmp/.apk
Method 3:
adb install -t *.apk

Apk Failed to install Error: [install\u failed\verification\u failure]

Apk install failed: [install\u failed\verification\u failure]

When “myapp.apk” is installed, the following error is obtained:

[INSTALL_FAILED_VERIFICATION_FAILURE]

You must allow unsigned applications. Installation is blocked by Android. Allow non market applications to be installed in settings.

You need to disable verification of APK during ADB installation. If the security settings are grayed out or do not work properly, try shelling the device and running at each API level (global, system, security) according to the settings in the settings database

$ adb shell settings put global verifier_verify_adb_installs 0

If you can really set it, it will prevent APK checking through ADB.

Sometimes you need to disable the package verifier and use:

$ adb shell settings put global package_verifier_enable 0

You can see here that these settings are in the global database:

http://androidxref.com/4.4.2_r2/xref/frameworks/base/core/java/android/provider/Settings.java#5015