Android - Gradle: error: package does not exist - android

I am trying to migrate a project that was previously developed in Eclipse over to Android Studio. The way the project was structured had caused a ton of issues when first importing. Most of those have been resolved, however there is one that persists.
The project uses zXing, which itself is a module in the project. There is no issue when referencing the module in code, autocomplete recognizes the library and features inside of it, but when Gradle tries to build I get this error:
error: package Intents does not exist
I've searched for similar scenarios but have not been able to find anything useful. This post is almost exactly what I'm dealing with. Any additional suggestions and advice would be greatly appreciated!

Looking into the build.gradle for the zXing library, changing 'minifyEnabled' from true to false seems to fix the issue.

Related

Gradle issue with sceneform - Program type already present: com.google.ar.schemas.lull

I am working on a project that will have a 3D model viewer in one fragment. In order to do so, I decided to use sceneform.
I downloaded sceneform plugin into Adnroid studio, downloaded and extracted sdk from Github, and I also copied libsceneform_runtime_schemas library into my project. I've added to my sceneform buil.gradle file line
implementation files("../libs/libsceneform_runtime_schemas.jar")
but that results in an error:
Program type already present: com.google.ar.schemas.lull.AabbDef
It is worth noticing that this is the first file in the jar under this path - which probably means that there will be more collisions.
If I'd try not to implement this library, then I get an error:
error: package com.google.ar.schemas.sceneform does not exist
I am using ar:core:1.17.0, and minSdkVersion 24 in sceneform gradle.
I've cleaned and rebuilt the project, Invalidate Caches/Restart, and added multiDexEnabled- although I am not sure if I did it correctly.
By using gradlew sceneform:dependencies I didn't find mentioned file.
I don't know how I can move forward, any help is much appreciated. If I can provide additional information, please let me know.
Edit 1:
I've also tried to work with
implementation files("../libs/libsceneform_runtime_schemas.jar"){
exclude ...
}
But I couldn't make it work. I wonder if that could be my solution.
Also, why does it try to implement this class since it already exists? Shouldn't there be some sort of check for that?
I solved my problem by restoring my project from repo to the last moment before including sceneform, and I proceeded with all of the steps again; Gradle dependencies to the libsceneform_runtime_schemas, min java 8, min SDK version, copying scenformscr and sceneformux to my project again, and lastly - upgrading all classes to AndroidX.
After two days almost I couldn't remove the error, and I don't know what went wrong before, but this time it works like a charm.
TL;DR - I removed the sceneform from my project and imported it again.

Type mismatch when creating a new ViewModel for Room implementation - kotlinx.coroutines obsolete since 1.3

I am building an app that will rely heavily on user data and plan on using Room to help manage and store their information. However, while following a tutorial I ran into a few versioning issues that I was having troubles resolving on my own.
Since I am fairly new to both Android development as well as using Room, I have been following this tutorial: Android Room with a View - Kotlin
I first noticed there might be some issues in step 3 when I updated my Gradle files. I was met by the following error on the last two lines of the dependencies block:
Library should be updated to be compatible with Kotlin 1.3
I was confused by this since the tutorial uses a variable of some kind to determine the library versions. I ran the app at this point and it seemed to work fine so I continued.
When I got to step 9, I also ran into additional errors which now prevent builds from completing:
Type mismatch: inferred type is kotlin.coroutines.experimental.CoroutineContext but kotlin.coroutines.CoroutineContext was expected
Type mismatch: inferred type is kotlin.coroutines.CoroutineContext but kotlin.coroutines.experimental.CoroutineContext was expected
This is on top of errors that implementations of kotlinx.coroutines.experimental are obsolete, however, I couldn't find references to libraries without experimental using Android Studio's intellisense.
What do I need to do in order to resolve these library issues and allow me to continue the tutorial?
To the best of my knowledge, here is the recommended way to resolve these issues.
To try and solve these issues, I started with the errors in my Gradle scripts to see if that would maybe resolve dependencies in the code. I did find this post, which I'm still not completely convinced is the best solution, but just following the first couple of suggestions in the top answer did clear most of my issues.
To be clear, I changed the following:
Changed the variable in the last line of the dependencies Gradle block to have a hard-coded version number (I did the latest as found in the kotlinx.coroutines repo). If possible, I would like this to be auto-generated again as the tutorial implies
Removed the kotlin block from the bottom of that same Gradle file
Synced my Gradle project
Update Kotlin and Gradle (I was asked by Android Studio, you might not be depending on your versions)
Manually removed problem libraries from code, and Alt+Enter'ed any missing libraries back into existence
If you update Gradle, you may also find it necessary to include the following in your Module: app Gradle file inside the android block:
packagingOptions {
exclude 'META-INF/*'
}
(* might be overkill for some, but the suggestion from this post didn't completely eliminate all of my errors.)
After all that, I was then able to rebuild the SDK which loaded to my phone with zero errors.

How to find which files are using a particular external library in an Android Studio project

The problem
Under "External Libraries" in the project view of an Android Studio project I have these libraries "stax-stax-api:1.0.1#jar" and "xpp3:xpp3:1.1.3.3#jar". They're causing me problems such that I can't build the project. I can't seem to figure out how they got there or where they're being used.
The error message I get when I build right now is:
"Error:Error: xpp3 defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]"
The error message is good except that it doesn't tell me who's using this lib in the first place.
The question
Is there an easy way to find out where they're being used in the project? Or even a way that it's easy but doesn't require looking at every file? It's a multi module project with lots of files. If I could delete them this would tell me but there's no delete option.
This could be something really simple that I'm overlooking. Any help appreciated. Happy to add more info as requested.
What I've tried
I've tried to "Analyze Dependencies" but it doesn't show me any references that I can see.
Update: I forgot to mention that I've also tried ./gradlew app:dependencies but it only tells me that my project depends on these libraries. I already know this. Is there a way to get some more specific information so I can remove the libraries?
Update 2: The accepted answer does work but I needed to redirect console output.
gradle app:dependencies
It will show you the dependencies tree of your project
At this link it is explained quite well about the command and how to use it.
Use this to redirect console output if it's clipped:
./gradlew app:dependencies > dependencies.txt
Project can be explored in "Project-tool-window" to have a look at the used external libraries which are not visible in "Android tool Window".
https://www.jetbrains.com/help/idea/project-tool-window.html
That way I solve my problem. Hope it help.

Hacker News Android Client: "Cannot resolve symbol 'MainActivity_'"

I'm currently working on a fork of the Hacker News Android client to implement a pull-down refresh feature for the news feed. However, after I imported the project from Github to Android Studio, I get the following error:
Cannot resolve symbol 'MainActivity_'
for not only MainActivity but also for several other activities used by the app. This error makes sense because if you look in the project directory, none of the activity names end in an underscore "_". However, these activities are referenced with the underscore in the Android Manifest. This leads me to think that I somehow imported the project into Android Studio incorrectly, but I'm really not sure.
Yesterday I was able to resolve this issue with Build > Clean Project, and then Build > Rebuild Project. However, today I reopened the project, the same issues arise, and these actions no longer fix the problem. Any ideas?
You should AndroidAnnotations library in the project.
For this configuration, please refer to here.

Android ADT Eclipse: com.android.common and com.android.ex imports could not be resolved

I'm trying to build Google's open-source Calendar app for Android (source here: https://github.com/android/platform_packages_apps_calendar), so that I may pick apart its code a little bit. When I import the freshly-cloned project into eclipse, I get a bunch of ____ cannot be resolved to a type errors. Looking closely at the types that aren't resolved, the root cause seems to be:
The import com.android.common cannot be resolved
The import com.android.ex cannot be resolved
I've been googling and I can't seem to figure out what's going on? I must be missing some library? I have everything in the Android SDK Manager installed, even the optional libraries. I've tried cleaning and fixing build path properties, etc. The errors remain.
Anyone have any idea what I can do to get this thing to compile?
I have managed to add almost all the required dependencies and now i got an almost-running version.
Kindly, check it out from here
You can also check the last commit, it contains all what i did to get this running version.
Have a nice day :)

Categories

Resources