Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a library (android-support-v7-appcompat) in IntelliJ IDEA

I created a project, copied the resource files in the project, library, added it to the project structure, prescribed style Theme.AppCompat. Compiled without errors, but when you start the relegation Exception:

08-03 00:50:00.406: ERROR/AndroidRuntime(4055): FATAL EXCEPTION: main         java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable         at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:98)         at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)         at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)         at com.example.SampleMetrRost.CentralActivity.onCreate(CentralActivity.java:12)         at android.app.Activity.performCreate(Activity.java:4636)         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1051)         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1924)         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1985)         at android.app.ActivityThread.access$600(ActivityThread.java:127)         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)         at android.os.Handler.dispatchMessage(Handler.java:99)         at android.os.Looper.loop(Looper.java:137)         at android.app.ActivityThread.main(ActivityThread.java:4476)         at java.lang.reflect.Method.invokeNative(Native Method)         at java.lang.reflect.Method.invoke(Method.java:511)         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:816)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:583)         at dalvik.system.NativeStart.main(Native Method) 

Help me, please. Spent all day today.

like image 505
Alex Malkov Avatar asked Aug 02 '13 20:08

Alex Malkov


People also ask

How do I add the v7 Appcompat support library?

In the Properties window, select the "Android" properties group at left and locate the Library properties at right. Select /path/to/appcompat/ and Click Remove. Click Add to open the Project Selection dialog. From the list of available library projects, select v7 appcompat library and click OK.

Where is install support library in Android Studio?

Downloading the Support Libraries Start the android SDK Manager. In the SDK Manager window, scroll to the end of the Packages list, find the Extras folder. Select the Android Support Library item. Click the Install packages button.


2 Answers

Using Gradle

If you are using Gradle, you can add it as a compile dependency.

Instructions

  1. Make sure you have the Android Support Repository SDK package installed. Android Studio automatically recognizes this repository during the build process (not sure about plain IntelliJ).

    Android Support Repository

  2. Add the dependency to {project}/build.gradle

    dependencies {     compile 'com.android.support:appcompat-v7:+' } 
  3. Click the Sync Project with Gradle Files button.

EDIT: Looks like these same instructions are on the documentation under Adding libraries with resources -> Using Android Studio.

like image 97
Austyn Mahoney Avatar answered Sep 29 '22 20:09

Austyn Mahoney


Without Gradle (Click here for the Gradle solution)

  1. Create a support library project.

  2. Import your library project to Intellij from Eclipse project (this step only applies if you created your library in Eclipse).

  3. Right click on module and choose Open Module Settings.

  4. Setup libraries of v7 jar file Setup libraries of v7 jar file

  5. Setup library module of v7 Setup library module of v7

  6. Setup app module dependency of v7 library module Setup app module dependency of v7 library module

like image 40
Tsung Wu Avatar answered Sep 29 '22 21:09

Tsung Wu