Tag Archives: android-studio

Android Studio: Gradle project sync failed [How to Solve]

Question:

Unable to find method ”java.lang.String org.gradle.api.artifacts.result.ComponentSelectionReason.getDescription()

Reference:

gradle issues details in discription – Stack Overflow

Solution:

Upgrade Android Studio.

Stack Overflow says to upgrade IntelliJ Idea. Similarly, The version of Android Studio is too low, and does not match the gradle version.

[Solved] Android Compile and Package Error: Invalid keystore format

Problem description

Running an old open source project, compiles the following error.

java.io.IOException: Invalid keystore format
Execution failed for task ':app:transformDexWithInstantRunDependenciesApkForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "C:\Users\a do\.android\debug.keystore": Invalide keystore format

Solution

According to the error message, there is a problem with the debug signature format.

We only need to open the c drive, in the current user’s directory, there is a .android directory, delete the debug.keystore inside.

If it prompts that the process is occupied, exit Android Studio first. Then delete it again.

Finally re-running the project, will automatically generate debug.keystore.

[Solved] Resource compilation failed (Failed to compile values resource file…

Resource compilation failed (Failed to compile values resource file /home/fanbin/AndroidStudioProjects/BookTest/app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml. ]


Resource registered by this uri is not recognized (Settings | Languages & Frameworks | Schemas and DTDs)

Reason: In color.xml, the color resource does not contain “#”, i.e. #FF000000, which causes this compilation error!

as shown in the figure below, the # number is not added to line 6.

Note: there are other situations that may cause this error. 

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

[Solved] Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit va

Manifest merge failed: when the corresponding component defines an intention filter, you need to specify an explicit value for Android: exported for Android 12 and later applications. See https:developer.android.comguidetopicsmanifestactivity-elementexported.

Manifest merger failed : 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.

Solution:

1. you need add  Android:exported to specify an explicit value

2. Add android:exported = "true" in the list file.

app:kaptDebugKotlin no error message [How to Solve]

Execution failed for task ‘:app:kaptDebugKotlin’.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)

 

Solution:
Run your application with ./gradlew clean build command to see what’s exactly wrong with your code. Just paste it into the Terminal in Android Studio.
Run gradlew clean build in Terminal to verify the compilation. If there are errors, the detailed code information will be listed here and then you can fix it.

Android studio NDK setting is gray and cannot be solved

Android studio NDK is set to gray

After clicking File->Project Structure, the screen that opens cannot be configured with NDK localtion

The solution is to configure the ndk path directly in local.properties

My settings path:

sdk.dir=E\:\\thirdparty\\Android\\Sdk
ndk.dir=E\:\\thirdparty\\Android\\android-ndk-r21e-windows-x86_64\\android-ndk-r21e

Failed to transform file ‘xxx‘ to match attributes [How to Solve]

Failed to transform file ‘xxx’ to match attributes when opening previous projects.

I opened the previous project and encountered a Failed to transform file ‘xxx’ to match attributes error.

There is a problem with the added dependency cache

Solution:

C:\Users\Administrator\.gradle\caches\modules-2\files-2.1 directory, find the conflicting files, delete them, and recompile

Supplement:

If an error is reported:

Null extracted folder for artifact: ResolvedArtifact(componentIdentifier=cn.jiguang.sdk:janalytics:2.0.0, variantName=null, artifactFile=C:\Users\dell\.gradle\caches\modules-2\files-2.1\cn.jiguang.sdk\janalytics\2.0.0\4abdfc462a6164fa5629301f8682a8adb7d3d332\janalytics-2.0.0.aar, extractedFolder=null, dependencyType=ANDROID, isWrappedModule=false, buildMapping={__current_build__=D:\Android\project\build\。。}, mavenCoordinatesCache=com.android.build.gradle.internal.ide.dependencies.MavenCoordinatesCacheBuildService$Inject@5859a341)

This error is also caused by file conflicts

AAPT2 error: check logs for details [How to Solve]

First, state that there are several reasons for this error

Here are my personal solutions to this error:

1. First, find gradle Properties file, open

2. Write “Android” in the space After enableaapt2 = false, click sync now

3. Errors will occur after synchronization. Don’t worry. Delete what you wrote and synchronize again

There is no problem running after resynchronization (personal situation)

[Solved] Android Studio Error: CreateProcess error = 206 file name or extension is too long

When Android studio develops Android projects, the error “CreateProcess error = 206” is easy to appear every time it runs. The console error message says that the file name or extension is too long. I used openjdk to solve this problem. I found many ways to solve it. For a long time, I can only restart Android studio or forcibly end the JDK process in the application manager. Later, I just changed the open JDK to Oracle JDK.