My imported project has errors importing common classes. For example in Context.java, the following lines (there are more in other classes) are in red and give the message "Cannot resolve symbol: 'lastPartOfThePackage'"(lastPartOfThePackage being AttrRes, IntDef, DisplayAdjustments, etc.):
Trying to solve the problem, I have tried everything I have read in other SO questions, but I keep getting the errors:
Invalidated cache and restarting.
Installed SDK Build Tools, SDK Tools, SDK Platform-Tools
Installed API 23 and API 16 SDKs (including the Google APIs)
Deleted .iml and idea folder and reimported the project
Cleaned, synced and rebuilded the project.
Deleted both "proguardFiles" lines from build.gradle
I also checked in my sdk folder for a annotations.jar file, and it's there.
What am I doing wrong? I have worked hard trying to solve it but I don't think I'm capable enough to fix it.
By default this should be included with appcompat, but try to add to your dependencies
compile 'com.android.support:support-annotations:23.1.0'
and sync Gradle.
biuld->clean project it would help.
That is because of #hide in android source code. Actually Android is not allowing developers to use some classes.
check your SDK API source code for #hide.
A solution is to use modified SDK which contains hidden classes. you can find it here https://github.com/anggrayudi/android-hidden-api
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 have a problem importing the PagerSlidingTabStrip library into Eclipse, I get multiple errors and I know this happens because the library was built using gradle.
I tried to follow this answer but I can't find use as source folder in the build path menu.
I've never used gradle previously and don't know how to go about this in Eclipse. Please guys, help most of us who have this problem out of our dilemma. Would be very grateful.
Okay in the end this was what i did:
I checked the build.gradle file of the library for target and min sdks. I then put what i found in the android manifest.xml which I know Eclipse uses.
I deleted the build.gradle and gradle.properties files.
Made sure the project was marked as a library. And it works!
I think the most crucial step was to check the build.gradle for the sdks and whatever else the project requires and replicating that the way it should be in the manifest file.
I have problems compiling my Android app with Gradle. I'm a newbie with Gradle, so...
It seems that Gradle cannot resolve correctly v7 compat library. This is the code where I use it:
MenuItemCompat.setOnActionExpandListener(mSearchItem,
new MenuItemCompat.OnActionExpandListener() {
#Override
public boolean onMenuItemActionCollapse(MenuItem item) { ...}
And this is the error I get from Gradle:
C:\>gradlew build
error: cannot find symbol
new MenuItemCompat.OnActionExpandListener() {
^
symbol: class OnActionExpandListener
location: class MenuItemCompat
I can build this from Android Studio smoothlessly.
I've tried adding the compat library jar manually to my lib directory and adding a dependency in the gradle.build file but it doesn't work.
Problem is probably the missing appcompat repo in your Android SDK.
Probably you are using 2 instances of gradle and Android SDK. Android Studio comes bundled with it's own Android SDK, so updating this wont change your previous installed one. Also normally you would start a Gradle project in Android Studio with a Gradle-Wrapper that handles manageing the gradle instance on its own (usually it will get downloaded into your %USER%/.gradle folder)
I also guess you downloaded gradle and that instance is what you use through the commandline. So to fix this just update your none-android studio android sdk (also check all the repos)
More to the Issue:
Android Library Projects won't get bundled as a jar since they need additional resources. The format for this is AAR, which to my knowledge cannot be build directly as for now. Also the gradle android plugin does not work with local AARs, only from maven/ivy repositories (this is a design descion and on purpose)
Finally, I found the issue, thanks to for3st.
Well, I didn't know that Android Studio SDK Manager and the SDK Manager that I downloaded on my own from the android web page did not refer to the following. That's the main issue here. Other issues were related to the problem:
I had such an old version of Android Studio (0.2) that I had to upgrade manually with the zip installer applying the patch. It seemed to work fine, but I'm not absolutely sure, so I uninstalled it and installed Android Studio 3.2 from the android developer site, then used the IDE mechanism to upgrade to 3.6. From now on, I'll enjoy easier upgrades.
Then I got lots of issues with Gradle, related to the version and all that, so I downloaded from the Gradle site the 1.8 version, placed somewhere in my disk, edited Android Studio settings to use this and edited the "gradle-wrapper.properties" to use the proper version.
More issues I got were due to downloading the required API versions that I targeted in my project, as well as matching the minSdkVersion and targetSdkVersion in AndroidManifest.xml and gradle.build files.
Then I checked my project structure and made the correct adjustments or added the "sourceSets" section in my build.gradle files.
Finally, I copied my third party dependencies (joda.time, android.v4 support) to my lib folder.
I'm not sure which one solved the issue, but all of this solved it for sure. I decided to put all this in order to help someone who gets stucked. Use this as a checklist.
Help needed!!!! Stuck for 2 weeks on this and help needed.
I've recently imported the facebook sdk for android and its projects into my workspace. It shows up errors and the problems:
Archive for required library: '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/libs/._android-support-v4.jar' in project 'FacebookSDK' cannot be read or is not a valid ZIP file
And the samples get errors along the line of:
The container 'Android Dependencies' references non existing library '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/bin/facebooksdk.jar'
The things I have done following the other discussions without any success are
cleaned project
set the Facebook SDK as library
looked at the build path section and added external jar consisting of facebook/libs
imported fb sdk like 20 times and into different folders.
made sure my java compiler was 1.6
HELP would be very greatly appreciated!!!!
Take the lastest version of android-support-v4.jar (in your sdk environement : sdk/extras/android/support/v4/android-support-v4.jar) and replace in your project and library project do not create conflict.
The steps to importing a library are:
Download the library
Place the library in the libs folder of the project.
Build the project
Do Not attempt to import the library using some import wizard.
I suspect either your download was corrupted, and you need to do it again, or you put the file into the wrong directly.
I think your problem is that the android.support.v4 versions are different, take the one from your project and replace the one in the Facebook sdk lib folder, it should dismiss the clash.
As per your question, I think you are not able to compile once you add the SDK to your project. Do you get an error saying unable to run as library?
If so that means you have included this as library and create your project as a library to be used further. It is a common mistake that I have seen many people do when they try to import a library to use and tick mark the checkbox is Library. This actually means you want this project to be treated as a library for future use. Just try to add the SDK and do not tick mark the checkbox and this project will run fine.
Many forums will just tell you to tick that checkbox and you will be stuck on this error for long time.
For any .jar file related issues you have to make the .jars files compatible as there hashing a problem and the two jars are not compatible with each other (a version issue).
although there are many questions with a similar title, I could not find the solution to this issue.
I have an Android project in Eclipse which references ActionBarSherlock 4.0.2 as Android library. In addition, I have added the JARs for ACRA and Google Analytics in the /libs folder. The support v4 jar is taken from ABS libs.
The project's Java Build Path looks like this
When exporting through the wizard I get the "Conversion to Dalvik format failed with error 1" error.
Cleaning, removing all Android Dependencies and clicking on Fix Project Properties and cleaning does all not work.
Any idea?
EDIT:
I missed some info: I'm doing this on Mac OS 10.6.8, Eclipse Indigo, Android SDK Tools r19 and ADT plugin v18.
project.properties file includes the proguard.cfg file: commenting it does avoid the issue.
I actually managed to overcome the issue, here soem details if they can be of use to anybody:
I first tried everything from clean to close/reopen project etc etc etc
I finally too the latest beta of proguard from http://sourceforge.net/projects/proguard/files/ and replaced the /lib folder in android-sdk-macosx/tools/proguard with the one from the beta version (proguard4.8beta1) and .. it works!
I had the same issue after updating to ADT 20 (released with Jelly Bean), and similarly, all the old solutions (clean, rebuild, etc.) didn't help. Taking a clue from omoling's answer, I updated my Flurry jar to the latest from their website... and the problem cleared up.
So, if you're having this problem, try updating any/all external libraries that your project uses.