So I'm developing a cheesy app to make posts to train myself in android before I work on my firm's real app project. I'm running into a bug that's giving me a very difficult time though.
I was given a list of library dependencies that I was to use, and have my build.gradle file set up to load them in. It syncs fine, so I assume it's done right to the best of my knowledge:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.squareup:otto:1.3.7'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'io.realm:realm-android:0.80.1'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.1.1'
}
And I have actually installed the android support library AND repository:
And yet I still try and launch the app and get the following stack trace:
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$attr
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:286)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.anglersatalas.twitstagram.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
at android.app.ActivityThread.access$900(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5487)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Everywhere else on Stack Overflow I've seen has the solution as adding the appcompat v7 libraries as they say to do on the android website, which I've demonstrated I've done above. I can't figure out for the life of me why this is still happening. Looking at the stack trace, it breaks in my MainActivity at the setContentView() method:
package com.anglersatalas.twitstagram;
import android.os.Bundle;
import com.anglersatalas.twitstagram.R;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.anglersatalas.twitstagram.api.PostService;
import com.anglersatalas.twitstagram.models.Post;
import java.util.List;
import retrofit.RestAdapter;
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.anglersatalas.twitstagram.R.layout.activity_main);
TextView tv = (TextView)findViewById(com.anglersatalas.twitstagram.R.id.textView);
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint("10.0.0.248/testserver/backend/web")
.build();
PostService service = adapter.create(PostService.class);
List<Post> list = service.getPosts();
String str = "";
for(Post p : list){
str += String.format("%s\n", p);
}
tv.setText(str);
}
...
}
Clicking through to the class file that is calling the method that throws the exception, it shows that it can't find 'android.support.v7.appcompat.R;':
My coworkers and I are at a loss. Any suggestions as to how to remedy this?