I'm trying to include in my project GreenDAO ORM, useless to say that there is no good tutorial that makes it work from scratch and there is ridiculous documentation on the official site. I used this greendao tutorial and made all intermediary steps to generating classes with gradle task. But now I'm stuck, Android Studio gives me an error for every generated class like:
Cannot resolve symbol 'AbstractDaoMaster'. All imports are actually in place but there is no way to make it work.
Things I tried:
invalidating caches
updating AS to 1.2.1.1
I have iMac OS X Yosemite 10.10.2
I have no clue what to do next.
The documentation on the official site it's a bit old, for Eclipse projects. Using Android Studio I always follow this tutorial, it worked always like charm.
I am sorry I didn't find your question in time - the answer was already in the 2nd part of the tutorial you mentioned:
compile files('libs/greendao-1.3.7.jar')
For the future, I really recommend adding Gradle dependency for greenDAO, instead of a jar file. It's more flexible and easy this way. Just add compile 'de.greenrobot:greendao-generator:2.1.0' to build.gradle and sync it. You can always check the last version here.
See this blog post for a step by step tutorial with explanation.
I actually had to update build.gradle in the app module with:
compile files('libs/greendao.jar')
and manually sync gradle scripts with project files. After that, all dependencies are met.
Related
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.
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.
I followed the official migration: https://developer.android.com/jetpack/androidx/migrate
The migration worked perfectly.
In my project, I use several third libraries. The complete build of my entire project works.
BUT now from Android Studio, I have a lot of syntax errors (from the editor, not after the build!). ie with the third-party "advrecyclerview" where the property "itemView" doesn't know now because:
So how can I change editor syntax analysis, etc. have you got some solutions?
Thank you very much
In your question you are using the wrong recycler view.
If you follow the link you posted, you will see the new package should be
androidx.recyclerview:recyclerview:1.0.0
(which means androidx.recyclerview in imports)
You need to make sure to change the XML to match
Edit
As it is in a library, make sure to enable Jetifier to auto-fix the libraries. It can still fail, but it does a good job for the majority.
You need to put the following gradle.properties:
android.enableJetifier=true
android.useAndroidX=true
More information on this is in the migration document
Ok guys, I found the problem: from Android Studio, I did "Invalide Caches and Restart", and the editor syntax works perfectly now.
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.
I have followed the procedure as described here : Setup
I have clicked on the little 'Sync project with Gradle' button. Gradle and Android Studio seem to find everything but then I can't actually use the gms code. If I try to import, I will get autocomplete for com.google.android.gms but no further. I have updated all the packages with Android SDK Manager.
I'm running Android Studio 0.4.2.
My minSdk is set to 9
my build.gradle includes compile 'com.google.android.gms:play-services:4.0.30'
As far as the procedure is concerned I should be ready to code, but it just doesn't work. Any ideas?
[Edit, added info]
I can find the ComGoogleAndroiddGmsPlayServices3265.aar file in my exploded bundles directory. Inside of that file I also find the common directory and inside that I find the GooglePlayServicesUtil.class (which is what's not being found in my app)
I am lost.
[Edit 2]
The problem is not specific to Google Play Services OR Android Studio. I tried adding another library (HoloColorPicker) and had the same results. However, I was able to add the library's resources to my project! I was able to add them in my XML layouts and view them in my application. I was able to interact with them, they worked fine. The problem arose again when I tried to reference them in the code. Exactly like the case with gms, I had code completion when trying to import up to the point of the actual class, and I could not declare the class in the code.
I was able to use the library by cloning it and importing the project.
Also, this is not an Android Studio problem because the same thing happens on the command line with "./gradlew clean build"
This is a current bug in Android Studio: https://code.google.com/p/android/issues/detail?id=64508 to be fixed this week.
The workaround is to close the project, delete the .iml files and .idea project and re-import the project.
Keep Your compile 'com.google.android.gms:play-services:4.0.30' as very first line in build.gradle dependencies like
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:+'
}
`
Open File> Project Structure and do the following steps
Select your main module in which you want to add dependency and click on OK.
Now try to import.
I think the most important question is what you want to achieve. Not all code is under this package. Not even sure which one is.
As noted before, this is a bug with Android Studio. It just don't recognize the path for classes and shows you like if there is an error. If you try compiling you'll see that everything just work fine.
A googler recently said it'll be addressed in this week release, so, be patient and lets see whats coming.
The fact that AS is in Preview mode tell us this sort of things are going to happen :)
Android studio is crazy one, I think.
It's removed "Import module" function and you can do "New module" only.
If you are developed on Eclipse, you need export all your projects to Gradle before switch to Androids studio (WTF?)
I prefer "IntelliJ IDEA Community Edition", although It's similar Android studio but it's better than Android studio (at least until now). You just import your project as eclipse format, IntelliJ IDEA will detect dependences libraries automatic (May be you need import jar libraries by hand) and rebuild project. That Done.