No resource found that matches the name - Android Studio - java

I just downloaded Android Studio and have created a new project.
Right off the bat, I'm getting two errors:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.test.testapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
and my installed packages:
What is messed up here? Thanks

In your gradle, compileSdkVersion is 22 while your support library version is 23. The two should match.
See Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

I also had same problem now. I tried below steps and worked perfectly.
In .gradle change like this
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v13:23.0.1'
}
You'll get error in style file change it as below
<style name="AppTheme">
<!-- Customize your theme here. -->
</style>
modify your main_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="#+id/action_settings" android:title="#string/action_settings"
android:orderInCategory="100" android:showAsAction="never" />
</menu>
In MainActivity remove AppCompatActivity like
MainActivity extends Activity

Related

Cannot resolve symbol Theme.MaterialComponents.Light.NoActionBar (Android Studio)

I've got an error for 'Theme.MaterialComponents.Light.NoActionBar' in styles.xml (the 'Theme.MaterialComponents.Light.NoActionBar' is colored red because of error) after several gradle update. My component are also not well arranged according to my idea of designing.
I've already clean and rebuild project, invalidate caches/restart, update the gradle (maybe not the correct answer) and there's no answer for this. I just think maybe I'm the only one that have this problem maybe for my beginner level problem :')
styles.xml
`
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/hitam</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
`
Project gradle
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
'
App gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
defaultConfig {
applicationId "blablabla"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '29.0.1'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.10.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
}
apply plugin: 'com.google.gms.google-services'
buildToolsVersion = '29.0.1'
}
`
I expect the error is not visible when there's like no one in this earth that have this error. PLEASE HELP T_T
The Material Components themes are included in the Material Components for Android library.
Since you are using androidx library just add this dependency in you app/build.gradle file.
dependencies {
// ...
implementation 'com.google.android.material:material:x.x.x'
// ...
}
Currently (April 29, 2022) the latest stable version is
implementation 'com.google.android.material:material:1.5.0'
Here you can find all the info the setup.
The reason why the MaterialComponents theme does not show is because you did not include the required Material Components library in your app/build.gradle:
dependencies {
implementation 'com.google.android.material:material:<version>'
}
The currently available versions are listed on the project's GitHub releases.
Add the dependency on Android’s Material in /android/app/build.gradle:
dependencies {
// ...
implementation 'com.google.android.material:material:<version>'
// ...
}
To find out the latest version, visit Google Maven.
Set the theme in /android/app/src/main/res/values/styles.xml:
//<style name="LaunchTheme" parent="Theme.AppCompat"> - remove
<style name="LaunchTheme" parent="Theme.MaterialComponents.NoActionBar"> - add

Theme Error - how to fix?

Tried Many Solution But No Helped
Ref : Failed to find style 'coordinatorLayoutStyle' in current theme
But not Helped
Render Problem:
Failed to find style 'coordinatorLayoutStyle' in current theme
Tip: Try to refresh the layout.
build.gradle file of my project is :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "*****"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0-alpha1'
}
main Activity XML code
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.bottomappbar.BottomAppBar
android:id="#+id/bar"
style="#style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:navigationIcon="#drawable/ic_menu"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:fabAttached="true"
app:backgroundTint="#color/colorPrimary"
app:fabCradleVerticalOffset="12dp"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bar"/>
</android.support.design.widget.CoordinatorLayout>
Why I am Not changing compiled SDK version 28 to 27
bcz I want to use Bottom app bar
Bottom App Bar Material Design
App Bars:Bottom- Material Design
This is a bug in 28.0.0 and the only fix(workaround) is adding this to your Build.gradle:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.1.1"
}
}
}
}
Which somehow, this bypasses the issue and uses 27 support library for that. Otherwise, you may wanna update your Android Studio to canary channel version or using backward support library like 27.1.1 or etc.
This error was occurred in your Rendering Layout which is a part of Studio Not in any files or Library
Try adding "Base" before Theme in styles.xml as show : -
"Base.Theme.AppCompat.Light.DarkActionBar"
Please restart Android Studio by selecting the menu option "File" →
"Invalidate Caches / Restart"
Workarounds: Try rendering with M preview using AS v1.3 preview OR
use FrameLayout for designing and change to
android.support.design.widget.CoordinatorLayout while debugging.

Error when Multidex Enabled

I've recently had to enable multidex in my android studio project, this is built with imported module. It's doing well in the main project, but showing multidex problem in the project built with imported(from the main project) module. I have followed this documentation to enable multidex. As the application tag is not overridden , so i've followed the method related. Now i'm getting this error:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [E:\something\SalesDemo >Updated\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't >read [E:\something\SalesDemo >Updated\app\build\intermediates\classes\debug(;;;;;;**.class)] (Can't read [com] >(Can't read [smth] (Can't read [infolinkplus] (Can't read
[some.class] (Duplicate zip entry
[com/abc/def/some.class]))))))
Here's my build.gradle:
apply plugin: 'com.android.application'
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
// buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.abc.def.somethingotherthing"
multiDexEnabled true
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 22
versionCode 16
versionName "0.0.16"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//implementation 'com.android.support:multidex:1.0.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.3'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'joda-time:joda-time:2.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile project(':infolinkplus')
}
And the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.abc.def.somethingotherthing">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
...
//ACTIVITIES AND META-TAGS
...
</application>
</manifest>
After changes, i ran clean build and rebuilt but no result.
How can i overcome this problem? Thanks in advance.
You have to change your Manifest to provide MultiDex:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
or if you have custom Application class, you have to extend it with MultiDexApplication
public class MyApplication extends MultiDexApplication { ... }
Duplicate zip entry
[com/abc/def/some.class]
In your project you must be having a class with name some.class rename it to some thing else
Try this code...
i hope you done this things..
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
make class for application level..
public class MyApplication extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
android:name="MyApplication" > // here define that class name that extends by MultiDexApplication

"The following classes could not be instantiated " Whenever i add a library

i'm trying to add some library in my application like me.itangqi.waveloadingview.WaveLoadingView from : Github The first time works well but after first RUN I have this error :
The following classes could not be instantiated:
- me.itangqi.waveloadingview.WaveLoadingView (Open Class, Show Exception, Clear Cache)
I already tried Clean/Rebuild but still the same ( doesn't work ).
My build.Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "maa.maxbattery_batterypowersave"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'me.itangqi.waveloadingview:library:0.3.5'
testCompile 'junit:junit:4.12'
}
My Style.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#262626</item>
<item name="colorPrimaryDark">#262626</item>
<item name="colorAccent">#262626</item>
</style>

No resource found - Styles.xml and Theme.AppCompat.Light

I imported a working project from github and I find myself unable to run/rebuild project because of a problem with my styles.xml and build.grable.
Here are the links that I visited regarding this issue:
Theme.AppCompat.Light.DarkActionBar - No resource found
Android Errors : No resource found - Theme.AppCompat.Light.DarkActionBar, and Android Virtual Device
No resource found that matches the given name 'Theme.AppCompat.Light'
Fixing Error in styles.xml to generate R.java : No resource found name 'Theme.AppCompat.Light'
No resource found - Theme.AppCompat.Light.DarkActionBar
Can't Find Theme.AppCompat.Light for New Android ActionBar Support
And many more..Most solutions are old (5+ years) and the ones I tried did not work:
Add compile 'com.android.support:appcompat-v7:25.3.1' in your build.gradle dependencies
Import appcompat, the import button disappeared in the current version it seems
Recompile/Resync/Invalidate cache/Close project/Reimport from github
Adding library dependance in the module settings (I am asked to upload a file?)
Please be very explicit in your answers as to what to do (open X file, do Y) as I'm new with Android Studio.
Here are the main files:
Styles.xml:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.app.game.quizee"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And the errors :
Thank you for your time!
Gradle version: "2.3.1" was causing this in my case, fixed it by returning to version "2.2.3".
In another words change this line:
classpath 'com.android.tools.build:gradle:2.3.1'
to:
classpath 'com.android.tools.build:gradle:2.2.3'

Categories