Android Studio Java Module does not find dependencies - java

I always get problems in my Android Studio Projects when I accidentally update parts of the IDE.
Usually it is always grade which complains it can´t find build tools anymore what so ever. If anyone could give me a hint how to avoid it ( I really don't got to have the latest versions, I'd rather stick to one and avoid updates and broken projects) it would be very much appreciated.
But currently a even stranger problem occurred.
The Gradle build works but when running the code this error is thrown:
Error:(62, 22) Gradle: error: package com.apple.eawt does not exist
My build.gradle file is this.
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
My JDK versions in library/Java/JavaVirtualMachines are
1.6.0 , 1.7.0 and 1.8.0
in 1.6.0 the ui.jar ist included but as soon as I change the JDK in the project structure it tells me I must use java 1.8
Any help is appreciated!
EDIT: I managed to solve it by adding jar dependency into my build path.
I had to add the UI.jar which includes the eawt classes.
Now my application is complaining that it can´t find audio resources and images. They are in the resource folder, they worked before....
Does anybody got an idea what the source of these problems is? It's all connected, the missing com.apple.eawt which I had to add again and my resource files. What causes these problems?

Ok I found the solution myself. The jar archive which gets created by gradle was missing. I have no clue why it got lost, but after adding it again:
Module-rightclick-Module Properties-> add jar dependency-> search modulname.jar archive in module directory/build/... and add it, it worked fine again.
In my example as shown in my project folder it would be the javalib folder (module) /build/libs/javalib.jar (modulename.jar)
Here is the official documentation for this archive file:
I guess for newer versions things changed because I can't find those archives anymore in my newer projects. Does anybody know something about this?

Related

The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher

I am trying tog get my React Native app (with expo modules, but not built on expo) deployed to the Google Play Store, and I keep getting this error when I try to build...
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
project ':expo' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10
My issue us, the line that it seems to be referencing, project ':expo' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10 doesn't exist anywhere in my code, maybe in the node modules but I have no way of knowing.
I have absolutely no idea what kotlin is and never heard of it before this. I tried looking around for where to upgrade by kotlin-gradle-plugin, but thats nowhere in my app.json or package.json or any other config files. I saw some message boards with similar issues telling me to change this line inside of build.gradle
classpath('com.android.tools.build:gradle:7.3.0')
to make 7.3.0 match the version I need, but I firmly believe 7.3.0 is greater than 1.6.20, so I highly doubt that solution has any actual merits
Apparently, the current version of expo-modules are incompatible with the latest version of React Native (0.70.0) and how it compiles Android Builds. I downgraded react-native to 0.69.5. This ultimately led me to other issues but hopefully this can help somebody else.

Cannot resolve production code in tests after Android Studio Chipmunk automatically created modules

I'm currently using Android Studio to develop a multi-module project by test-driven-development methods. It went well until I updated my IDE to Android Studio Chipmunk from previous Bumblebee.
When I opened the project after the update, it seemed that AS automatically generated some modules for me. As you can see in the pic, those new names such as [main] and [unitTest] appeared in the project view automatically.
modules generated automatically
After this, I found that the classes and methods of my production code could not be resolved in my test code. AS told me after I pressed Alt+Enter that I should add dependency to the main module of my production code. And it added one line in the build.gradle file: "testImplementation project(path: ':app')". After syncing the gradle build, nothing had changed and it still could not resolve methods in my production code. I can still run the tests by executing gradle test tasks, but it is weird that I cannot use production code in my test code directly.
UPDATE:
For further information, I think this is a problem caused by the update from Intellij 2021.1 to 2021.2, since I re-installed AS Bumblebee and all seems worked fine. I also found this issue in JetBrains YouTrack that has an exactly same problem with me. Here is the link: https://youtrack.jetbrains.com/issue/IDEA-275566/Class-not-found-after-intellij-upgrade-2021-1-2-2021-2
This issue remains open and I've tried some other developers' reply in this issue to delete the .iml files, but the problem remains. I think Intellij 2021.1 and 2021.2 generate different .iml file in the .idea folder.
I was having the same issues in the first Android Studio Chipmunk release - all of my unit test source code was peppered with "Cannot resolve symbol" errors, but the code would still compile and run, and the tests would pass.
I found that I could temporarily workaround (i.e., "fix") the issue by adding a line to the build.gradle file like:
testImplementation project(path: ':shared:library:module')
But today I upgraded to the new Chipmunk release, with details:
Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+0-b1504.28-7817840 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
And the issue no longer occurs. I'm guessing the folks working on the IntelliJ platform found and patched the issue. 🙌

Restcomm Android SDK and libjingle

I am wondering how to get libjingle when checking out the SDK from git.
What I ended up doing was to add libjingle as compile dependency in build.gradle:
compile 'io.pristine:libjingle:11139#aar'
but looks like the interface is changed from what you use in the SDK, so not sure about what libjingle version to use.
Thanks.
Ok, so what we do to avoid the repo getting huge because of carrying binaries, we only place the binaries in the releases. So I'd suggest downloading latest .tar.bz2 from here and copying over native and non-native libs from restcomm.android.sdk/libs/libjingle_peerconnection*.jar and restcomm.android.sdk/libs/jniLibs/armeabi-v7a/libjingle_peerconnection*.so to the same locations in the source tree. That way they should be discoverable in the Android Studio project.
These are going to be turned into maven dependencies at some point to avoid such issues.
Now about io.pristine:libjingle:11139#aar that you used, it's going to be a problem as this build is much earlier than what we have in restcomm-android-sdk and indeed the API is different in some respects.

Getting a java.lang.NoClassDefFoundError for every jar file

I have recently reinstalled my computer, installed latest version of Android SDK and Eclipse.
And now every project that I have, I'm getting a "java.lang.NoClassDefFoundError" for every jar file included in every project.
I am a Java beginner, I have spend the last week on forums, but cannot get to fix it.
Could someone please help me ?
Thank you
You were probably using an out-of-date version of ADT prior to reformatting. Post ADT 17, libraries either need to be copied to the libs folder of your project, or they need to be marked as exported on the build path. Otherwise, the libraries will not be packaged with the APK binary, thus you will get NoClassDefFoundError when using those libraries.

Error when building apk - "Multiple dex files define Lcom/google/ads/Ad"

I've been tearing my hair out over this one, for the past 3 hours I've been trying to fix it but have been unable to. I've created an android app and I'm ready to put it on the android market but I get this error when trying to export to an apk.
Unable to execute dex: Multiple dex files define Lcom/google/ads/Ad;
I've read a bunch on the problem and tried quite a few solutions but nothing has seemed to help. I've cleaned and rebuilt, I've delete the bin folder, I've made sure that the bin folder is excluded build path. Nothing's worked. If anyone could help me I would really appreciate it.
Untick the admob jar file in the "order and export" part of the "configure build path".
On another post with a problem similar to yours the only thing mentioned that you have not already considered was updating Eclipse. I don't know how or what order that you have done these "fixes" but another poster mentioned that all at once he deleted the bin directory for his project, cleaned and rebuilt the project and restarted Eclipse. After that the error disappeared.
Good Luck- Lijap
For me the error was due to 2 different versions of AdMob SDK being included accidentally.
Removing one of them fixed it.
As other have noted, this problem should be due to multiple versions of Goodle's ad SDK classes being included in the app build. What I haven't seen yet is a note that the most recent Google Play Service lib includes classes that (at least) share the same names as some in the admob sdk-- for example, I came upon this error because I was trying to build with both admob sdk v.4.0.4 and the google-play-services_lib project as a referenced project; the latter contains google-play-services.jar which contains the package com.google.ads and many of the same classes as the admob sdk. Thus it appears that the google play services lib and the admob sdk cannot both be used in a given app. My solution was to remove the admob sdk entirely from the build.
I had the same or a similar problem. My problem was that my application imported a library which used a different version of AdMob SDK.
Details of my problem:
Library used AdMob SDK 6.3.0
Application used AdMob SDK 6.1.0
Fixed it by including the same version.
For me, I just have to take out the libs folder which contains android-support-v4.jar from build path and it worked.

Categories

Resources