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.
Related
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.
I have a working app that I've now converted to being a library project in Eclipse. When I attempt to include the library as a "Project Reference" in an empty app (no other functionality other than what it inherits from the library) it fails to build. I get the message Unable to execute dex: Multiple dex files define Lcom/facebook/android/R$attr;.
To try to work around this I tried to delete the Android Dependencies completely. But then I get a "Class not found exception" for classes in the library.
Is it possible to remove the Facebook dependency without also removing the app library dependency? I tried to delete the facebooksdk.jar file but was unable to do so since all the buttons are grayed out. (see screen capture below)
I also tried simply unchecking "Android Dependencies" in "Order and Export". That had no effect on the problem.
Your suggestions are welcome.
FYI, my project has 3 main components. All 3 are contained in the same Eclipse project folder (see screen capture):
Application "App_A"
Library_L (included as Project Reference in "A") It's worth noting that Library_L executes perfectly when I run it as a non-library project.
Facebook SDK 3.0.2 (included as Project Reference in Library_L (see screen capture)
Project References are used to include a library project (e.g., the Facebook SDK).
The documentation -- and books by balding guys -- show you how to attach an Android library project to your app, and it has nothing to do with "Project References".
Similarly, the documentation for the Facebook SDK shows you how to attach their Android library project to your app (see Step 6). They follow the standard Android library project approach, and that too does not involve "Project References".
Now, it is conceivable that there's something about a newer Eclipse version (I'm running Indigo) that causes "Project References" to show Android library projects as checked -- it does not do so in my version.
Make sure that you have properly set up the Android library projects, and see if that helps with your issue.
I'm developing an android application and I'm trying to use a library Sliding Menu (github.com/jfeinstein10/SlidingMenu). However, I have a problem in using the library in a clean project. I get
java.lang.NoClassDefFoundError: com.slidingmenu.lib.R$styleable
when doing
SlidingMenu slidingMenu = new SlidingMenu();
Configurations tested:
JDK tested 1.6u43, 1.7(latest)
Project target api = tried both Android 4.2.2 and Google API 17
SDK versions tested 21, 21.0.1, 21.1
Windows 8 Pro x64, Intel Core i7 3610QM, Nvidia GT660M, Samsung Pro 840 256GB SSD
Integrated both with Actionbarsherlock and without it.
I import the library, by creating an Android Project from Existing Code, marking "Is Library" in the android properties, and then referrencing it in the original application android properties (not via .jar)
Below links to code snippets, full stacktrace and screenshots of current configurations
Code snippet:
http://pastebin.com/2yzRC5AJ
Full Stacktrace:
http://pastebin.com/D7RQwuQd
I've been stuck on this for 3 days now... :/
I had to add the dependency two ways before I eradicated my noclassdef errors
Add the library.jar from /bin as dependency to your build path, make sure to select the Order and Export tab and select the check box as well for the new dependency.
Add the library via right mouse click on your project, then properties, then android then add library
Voilla
I struggled with this as well, and from a vast number of google searches, managed to piece this together.
Hope it helps..
Simple solution :
If your project already contain support library then just delete support library from library(jfeinstein10 / SlidingMenu) and then every thing works fine.you can do it after import also.
1) Just add the library to the properties of your project (ANDROID);
2) And mark the same in Order & Export property of (JAVA BUILD PATH);
I had the same problem. Since you're building the app with IDE, you need to tell the IDE that this module is a Library, thus defining the library in .properties file would be useless. Try change the IDE build file, I'm not familiar with eclipse, but in android studio this lines would be enough:
module.iml
<configuration>
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
Go to Manifast and change sdkversion to 11
I can't understand why am I getting this error:
When another people don't get it and are able to create a new project with inner navigation like that. powered by compatability library:
PS: I have every single package of android SDK Tools installed on my computer, and they're all up to date
It is because the wizard doesn't take the compatibility library into consideration. Set your minimum to 14 and then go and change the manifest after you have created your project and include the compatibility library.
In "Fragments for All", Xavier Ducrohet, Android SDK Tech Lead says Google releases an Android Compatibility Package by SDK Manager.
I've installed it, but, how can I use it now?
How can I integrate Android Compatibility Package in my project?
If you're using version 12 or later of the Eclipse Android support library, just right-click on your project, and choose Android Tools > Add Compatibility Library...
There is a .jar file called android-support-v4.jar in the directory {yoursdkpath}/extras/android/compatibility/v4/. Copy this into your libs folder in the root of your project and add the file to the build path in Eclipse.
Premier,
I followed the Fragments example on the Android Developers Blog to create a "backwards" compatible app using Fragments. In the article there is a brief mention of the Main activity that uses a layout with fragments.
The code for this activity is not interesting; it just calls setContentView() with the given layout:
What should be mentioned here is that this activity must derive from FragmentActivity and not Activity class. This threw me off for a while.
Good luck
Refer Using Fragment of Android Compatibility Package may help you
Check the "Step 2: Configuring the Build Path" Section here
This is easy with new Eclipse I downloaded. Provided you have all the paths for SDK etc setup correctly, Right click on Project -> Android tools-> and Hit "Add compatibility Library" it will add the JAR file