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

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'

Related

Android resource compilation error in values.xml

I am getting error shown below, it just came suddenly and I don't know what to do, I tried changing Complile sdk to 29, removed few unused res file. Restarted the android studio but this is same
Error -
Android resource compilation failed
E:\NotificationLog\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1096: error: :style>.
E:\NotificationLog\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1101: error: :style>.
E:\NotificationLog\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1106: error: :style>.
E:\NotificationLog\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1110: error: :style>.
E:\NotificationLog\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml: error: file failed to compile.
Values.xml(error part)-
<!-- <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>-->
<style name="parent">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="viewParent">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="parent.TextLayout">
<item name="android:layout_marginLeft">15dp</item>
</style>
<style name="modifiedEditText" parent="parent">
<item name="android:textSize">#dimen/newsMoreTextSize</item>
</style>
App Gradle -
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.appnotification.notificationhistorylog"
minSdkVersion 19
targetSdkVersion 28
versionCode 110
versionName "1.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
manifestPlaceholders = [
onesignal_app_id : 'ID',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE']
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'androidx.preference:preference:1.1.0-alpha05'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'
implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:multidex:1.0.3'
//gif
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.10'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//Showcase
implementation 'com.github.mreram:showcaseview:1.1'
//Fav
implementation 'com.github.ivbaranov:materialfavoritebutton:0.1.5'
implementation 'com.google.firebase:firebase-core:17.1.0'
// (Recommended) Add Analytics
implementation 'com.google.firebase:firebase-analytics:17.1.0'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'
// implementation 'com.google.firebase:firebase-appindexing:10.0.1'
//implementation 'com.android.installreferrer:installreferrer:1.0'
//Firebase
implementation 'com.firebaseui:firebase-ui-database:4.0.0'
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.1'
implementation 'com.google.firebase:firebase-storage:18.1.1'
implementation 'com.github.aakira:expandable-layout:1.6.0#aar'
implementation 'com.google.firebase:firebase-perf:19.0.0'
implementation 'com.onesignal:OneSignal:[3.11.2]'
//implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.0'
//remote
implementation "com.google.firebase:firebase-config:19.0.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-ads:18.1.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
Project Gradle-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:perf-plugin:1.3.1'
classpath 'io.fabric.tools:gradle:1.30.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public'}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven
{
url "https://maven.google.com"
}
maven
{
url "https://jitpack.io"
//Jitpack
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please if any can help me in this, I am not finding my way here
I Solved It by Removing below code from style.xml file
<!-- <style name="parent">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="viewParent">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="parent.TextLayout">
<item name="android:layout_marginLeft">15dp</item>
</style>
<style name="modifiedEditText" parent="parent">
<item name="android:textSize">#dimen/newsMoreTextSize</item>
</style>-->
I by mistake added styles in wrong place. :)

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

"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>

Java.exe finished with non-zero exit value 2 in Android Studio

This error came after when I added compile 'org.apache.httpcomponents:httpmime:4.2.3'. Can't find solution I also tried multiple dex file true in default config section. I also tried creating another app for testing which was running successfully.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
This is my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.qualwebs.assistme"
minSdkVersion 19
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.1'
compile 'com.android.support:design:23.1.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
}
The Android plugin for Gradle available in Android SDK Build Tools
21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android
Support Repository to the latest version using the SDK Manager before
attempting to configure your app for multidex.
Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:
Change your Gradle build configuration to enable multidex
Modify your manifest to reference the MultiDexApplication class
Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 23
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
In your manifest add the MultiDexApplication class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited
You can use
compile 'org.apache.httpcomponents:httpmime:4.5.1'
Read
https://developer.android.com/intl/es/tools/building/multidex.html
You have problem of multidex file so please add below dependency to your app Gradle file.
compile 'com.android.support:multidex:1.0.1'
Also add this line:
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
Also add below in Manifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited :
Try the following:
Change setting
Ctrl + Alt + S -> Compiler -> Gradle
InVM Options field write:
-Xmx2048m -XX:MaxPermSize=512m
Add in gradle
dexOptions { javaMaxHeapSize "2g" }
Thanks..!!
This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.
So, If you have to keep libraries and methods, then you can enable multi dex support by declaring it in the gradle config.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}

No resource found that matches the name - Android Studio

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

Categories