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.
Related
So when I try to build android app, I get these duplicate errors and also warnings about mapping new ns.
I tried many different configuration and sdks etc. For now my setup is:
Unity 2019.4.40f1
Android SDK, JDK and NDK downloaded as a modules from unity hub (I tried different ones, nothing changes)
Gradle 6.9.2 (already tried the latest one version, still same)
My target api is level 30 and minimum is 21.
I am using many libraries for my project like Branch.io for deeplinks, playfab, googleplayservices, facebook sdk etc. It might be the issue, but I am not sure.
I tried also export my project and it works surprisingly.
Also what's important I use custom gradle.properties file which looks like that:
Finally, I solved this by deleting old jars located in gradles templates location, for me: Assets>Plugins>Android
for certain compatibility reasons, I have to use Eclipse Neon for Android Development to develop an android app. Therefore I also have to use the newest Android SDK so I can implement some newest features.
Now, I am facing the problem that I cannot compile any Android app with Eclipse, because I get errors like
The import android.support cannot be resolved
ActionBarActivity cannot be resolved to a type
Error retrieving parent for item: No resource found that matches the given name "ThemeAppCompat. …"
upon building. As I found out, this is because Eclipse is missing the "Android support library" (android support library.jar ?) in the sdk folder. The reason for this is, as I found out, that this library is obsolete and has been replaced by the "Android support repository". It has not been installed by the Android SDK manager and cannot be installed anymore, but Eclipse still needs it apparently.
I searched a lot for a solution for this but all answers I could find was "Swtich to Android Studio"… Unfortunately, there is no way around using Eclipse for me. Is there any known way to include the support repository and make eclipse use it? I found this site
https://developer.android.com/topic/libraries/support-library/setup.html
and thought, maybe I can follow these steps to make my app to a gradle.build and then include the stuff from the repository and get my stuff to work, but unfortunately I could not find a way to realize this.
I changed the related section in the gradle.build file to this:
…
dependencies {
…
compile 'com.android.support:appcompat-v7:24.0.0'
}
…
but could not get the app being built.
Is there any known solution for this? I actually cannot imagine that I am the only one trying to develop an Android App with the new support repository file these days. Should I maybe manually insert the obsolete (but newest) android support library.jar file from an older IDE? Could this work?
Thank you many times for your help.
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
This error appears when creating a new Android Application module in Android Studio using Fixed Tabs + Swipes for navigation.
It says:
The following dependencies were not resolvable. See your build.gradle
file for details. - com.android.support:appcompat-v7:18.0.0
I'm targeting Android 4.0+ devices. Why is the compatibility library involved? One workaround is to install this library using the Android SDK manager, but I'm concerned my app will actually use this compatibility library when there is no reason to. The ActionBar and fixed tab navigation should be built-in to the Android 4.0+ framework right?
This happened to me with IntelliJ Idea 13 Ultimate when creating new Gradle Module. I was working on the app that supports Froyo. I had to manually add support libraries to the SDK. After that I was able to build just fine. Here is the screenshot of Project Structure settings for SDK that I have:
As you can see, support for v4, v7 and v13 which were added manually. Those will be associated with Android API 19 Platform (in my case). When you create next new Gradle Module, you will still need to go to Project Structure to select the SDK under Project, but you will not need to add support libs again. Hope this helps.
I installed the compatibility library anyways. Something I didn't realize is that you can't create your first module by using File -> New Module. You have to use File -> Project Structure -> New Module for your first module. It's really unintuitive. After I did this, then everything worked.
Today, I updated my Android SDK and Eciple ADT to the most recent versions (ADT Rev 22). After restarting Eclipse it is quite unhappy with the Build Paths whenever I reference custom libraries.
An example is shown in this screenshot:
My custom "Android Utilities Library" compiles fine, but everything that depends on it shows build path errors. E.g. when I investigate the build path settings for "Android URA Library" it shows me an error with the android_utilities_library.jar missing under "Android Dependencies" (which in fact is true, the libraries will be built to individual class files in bin/classes).
After reading the solution to Build path errors with library projects I tried to clean and manually build my projects in the correct order, but to no avail.
I've never dealt with this before, so I don't know how to attack the problem.
Any help is appreciated. Thx!
Installing the new Build Tools did the trick. They were not automatically included when I updated the SDK (probably need to run the update twice I guess).
I found a solution that works for me:
Go to Project Properties > Build Path > Order and Export
Then you have to check each checkbox.
In my case my libraries were restored
I hope it will help.
I can see that your project Android URA Library is referring to Android Utilities Library, then the problem should not relate to SDK/ADT update.
Please check:
Project Properties of Android URA Library, choose Project tab and make sure you added Android Utilities Library as dependency project. Otherwise, please add it.
If the problem is still existing, then Projects \ Clean All Projects
Go to libraries and check the build path of the dependent libraries. It should be same as your projects build path.
if you have import all the Dependencies in your workSpace.maybe you can:projetc-->build all.
I meet the problem,and it works well