Android Studio: Java Library Module Dependency Error - java

I've added a Java Library dependency module to the app module of my project. When I try to run the app I get this error:
...while parsing hai/shoplist/ItemBag.class
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException: Process 'command 'C:\ProgramFiles\Java\jdk1.8.0_05\bin\java.exe'' finished with non-zero exit value 1
I've tested the classes that I have in the module and I can even build it but the problem arises when I try to run the app.

Android doesn't support Java 8.
Add to your library build.gradle:
sourceCompatibility = 1.7.
It should solve your problem.

Due to Androids design, there is a limitation on how many methods your application may contain. You might have exceeded this amount. To solve this, enabled multidex support as explained here.
More information about it be found in the Android developer docs.

Related

Unsupported class file major version 59 in Android Studio with ReactNative

i'm trying to reBuild and compile my Android Studio project, it worked good before installing the new version of react-native-jumio-mobilesdk for react native. After upgrading that library to 3.9.1, i had this error and i have not been able to fix it.
> Task :react-native-jumio-mobilesdk:compileDebugKotlin FAILED
Execution failed for task ':react-native-jumio-mobilesdk:compileDebugKotlin'.
Could not resolve all files for configuration ':react-native-jumio-mobilesdk:debugCompileClasspath'.
Failed to transform bcprov-jdk15on-1.67.jar (org.bouncycastle:bcprov-jdk15on:1.67) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: C:\Users\UsuarioDA1.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.67\8c0998045da87dbc2f1d4b6480458ed811ca7b82\bcprov-jdk15on-1.67.jar.
> Failed to transform 'C:\Users\UsuarioDA1.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.67\8c0998045da87dbc2f1d4b6480458ed811ca7b82\bcprov-jdk15on-1.67.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 59. (Run with --stacktrace for more details.)
Please file a bug at http://issuetracker.google.com/issues/new?component=460323.
I have one entire week trying to fix it but so far I have not been able.
I appreciate your help. :D
For me the issue occured when I tried to update the firebase crashlytics gradle plugin to 2.7.1.
It was possible to fix it by setting android.jetifier.blacklist=bcprov-jdk15on in gradle.properties as mentioned here.
Try this :
clear project cache
upgrade packages for ex. in flutter we use flutter pub get
add :
android.jetifier.blacklist=bcprov-jdk15on
to your gradle.properties file and rebuild the project. if not resolved please refer to similar issue on github and google

Build Problem with AnysoftKeyboard (Android)

I am trying to build AnysoftKeyboard in Android studio.
I have java 9(jdk 9) and the appropriate ndk (android-ndk-r14b), as the creator in GitHub says.
I have also changed the local.properties file to shows to the correct paths.
Nevertheless I am still getting some errors.
You can find below those errors.
Run tasks error :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':base:compileDebugJavaWithJavac
java compiler errors : Caused by: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/sun/tools/javac/util/JavacMessages$ResourceBundleHelper
Caused by: java.lang.NoClassDefFoundError: com/sun/tools/javac/util/JavacMessages$ResourceBundleHelper
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.util.JavacMessages$ResourceBundleHelper
Here is a screenshot of the error :
AnySoftKeyboard Compile Error , Run Tasks Error
The project uses gradle, in which I am not familiar with, so if I have missed any important step-point, please guide me to solve it.
Is there something that I am missing and getting these errors? What should I do? Thanks in advance.
After following just the official documentation I successfully built a project. I think you just forget with setting JAVA_OPTS with adding java.se.* source as mentioned below. And that is why you have it in stacktrace error above, with missing java.se. resources.
To develop this project, you'll need:
Java 10 - get OpenJDK or AdoptOpenJDK.
Make sure you have the environment variable JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'. This is required to ensure the JVM is merciful with libraries that were not designed for Java9+ JVMs.
git
Android Studio
Android SDK API Level 28 installed. Set up local.properties file to point to it (that is, ensure you have sdk.dir=/path/to/android/sdk in it).
Android NDK r14b installed. Set up local.properties file to point to it (that is, ensure you have ndk.dir=/path/to/android/ndk in it).
Caused by: java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: com/sun/tools/javac/util/JavacMessages$ResourceBundleHelper
TO remove this error comment below line prone error.

Multiple dex files define Lorg/apache/http/HttpConnection with Gradle and Android Studio

Development environment:
OS: Windows 7
JDK: 1.8.0_66
Android Studio: 1.5, built Nov. 12 2015
Gradle: v2.8
build.gradle
libs folder
Project Structure
Exception
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/apache/http/HttpConnection;
Stuck with this issue for the past two days. Understood that there are multiple definitions of that class in the dependencies, but clueless on the fix. Was unable to get any of the answers on this topic to work.
On Eclipse this project / module runs without any issues. This is my first shot at Gradle on Android Studio. So,:
Is there a specific Android-Gradle plugin (or similar) that needs to be installed?
Adding dexOptions { preDexLibraries = false } also fails:
Error:(11, 0) Gradle DSL method not found: 'dexOptions()' Possible causes: The project 'XXX' may be using a version of Gradle that does not contain the method.
Any glaring error in the way things are setup here?

Project Not working after updating to API 23

Can anyone please help me with this? I dont know what does this mean.
To give you a back up I updated my sdk with 23 and then i got 101 errors regarding HTTPClient not being resolved. So i followed this link to remove that then I have this error of which i have no clue where to start with.
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\build-tools\23.0.1\dx.bat --dex --no-optimize --output F:\sagarDevanga\workspace\AndNrby\app\build\intermediates\dex\debug --input-list=F:\sagarDevanga\workspace\AndNrby\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/apache/http/ConnectionClosedException;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Make sure that your adt supports the version of api that you are running. See this link : https://developer.android.com/tools/support-library/index.html
To fix you should check in libs (.jar) and in your build.gradle if there are some libraries duplicated. This error happen tipicaly when you add a copy of the same library or a library that include a copy of another library that you have already added
Update also your support libs from SDK
Ok I have updated the question's title also so that other people also find it useful.So I will write a detailed answer about how this error occured in my project and the fixes I did and how I finally derived the answer.
1) I updated the SDK and then started to compile my project using the latest api i.e API 23. You can do that by going to File -> Project Structure ->Select your module.
Now in the right hand side window under properties the top two properties can be changed using in the drop down.
Then click on Apply and Ok.
2) So when you do this your app's build.gradle file will look like this. And now everything looks good. It will compile also. But when you run the project you will get a lot of errors by this name Error:(17, 35) error: package org.apache.http.impl.client does not exist Obviously if you are using them in your async tasks.
3) So when i got this error I did a lot of research here and there and then came across this link and added the HTTP CLIENTS jar files in the libs folder and then tried to run the program I ended up with this problem (problem mentioned in the question).
4) So after diggin around I found that the problem was HTTP methods which i used in the Async task were deprecated in the API 23 hence I landed myself in this mess.
5) Then what I did next fixed the problem for me. Refernce given here.
6) In your module's build.gradle file add this line useLibrary 'org.apache.http.legacy' like below.
7) Wait your still not done. Now go to your main build.gradle file and add this line classpath 'com.android.tools.build:gradle:1.3.1' like this . Now build and compile your project everything runs fine.
8) After all this steps the project works fine but I have a doubt in the last pic that i shared which is of the top level build.gradle file. Whether I should keep both the classpaths or just use this classpath 'com.android.tools.build:gradle:1.3.1' and remove the other one. If any one have any idea on this please help.
9) The problem was that they deprecated the HTTP Clients in the Latest Android API 23. Insted of HTTP Client you have to use HttpUrlConnection but if you want to continue using HTTP client for NOW follow the steps above.

use tools:overrideLibrary="org.springframework.android.rest.test" to force usage

I got the following error message:
Error:Execution failed for task ':Project1:processBetaDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 17 declared in library /Users/motianim/Project/mobile-ws/src/build/intermediates/exploded-aar/src/Projecct/unspecified/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="org.springframework.android.rest.test" to force usage
I tried following things to solve the issue:
installed google apis 17.
re-installed the android studio and the re-imported the project.
reboot of complete system.
I'm still having the problem.

Categories

Resources