Sam Piastry
Sam Piastry

Reputation: 39

Rendering issue in android studio android.support.design.widget.CoordinatorLayout

Firstly, I am just starting android development so please bear with my lack of knowledge.

Two things my gradle doesn't recognize

testCompile 'junit:junit:4.12'

L

But If i highlight the junit code in gradle then the project builds fine. What is the reason for this and will this be a problem later on in the development cycle. How to fix if so.

And my main function just doesn't recognize so many libraries.

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.mycompany.myfirstapp"
    minSdkVersion 8
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),                proguard-rules.pro'
        }
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//  testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:gridlayout-v7:23.1.0'
}

Second thing, even with gradle building fine I have rendering issue and preview of the design wont render no matter what. I did try solutions like
changing APK,changing themes from projects, adding appcompat in dependencies (there was only one v7:23.1.0). Nothing really helped. How do I fix rendering problem and start working in android studio?

 Rendering Problems The following classes could not be instantiated:
- android.support.design.widget.AppBarLayout (Open Class, Show Exception,   Clear Cache)
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  Exception Details     java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or   descendant) with the design library.   at   android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)     at android.support.design.widget.AppBarLayout.<init>(AppBarLayout.java:145)   at java.lang.reflect.Constructor.newInstance(Constructor.java:526)   at    android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:756)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:728)   at   android.view.LayoutInflater.inflate(LayoutInflater.java:492)   at   android.view.LayoutInflater.inflate(LayoutInflater.java:373) Copy stack to   clipboard  The surrounding layout (@layout/activity_my) did not actually include  this layout. Remove tools:showIn=... from the root tag.  

Upvotes: 1

Views: 7319

Answers (2)

ashish sharma
ashish sharma

Reputation: 11

Try this. I had the same issue with my tool.

screenshot

Upvotes: 1

Micah Smith
Micah Smith

Reputation: 51

Not an answer - but I am having BOTH of the exact same issues - and had tried commenting out the item you highlighted the same way. Hopefully someone chimes in -I will update if I figure this out.

Update: To resolve the junit issue - go to app>build.gradle (same place you commented out the line). In the android section above, add:

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
}

and then re-sync. That resolved that issue for me.

As for the other issue, when I went to the theme selector and chose "AppCompat.Light". Once I had selected that, the preview no longer gave the error. Though I should note - I'm unable to drag widget objects to the preview, like I can on my mac, so I still have to figure that part out.

Update 3: Got that part figured out as well - had to select the app>src>main>layout>content_main.xml - then I could start dragging stuff over.

Upvotes: 1

Related Questions