I've added the library for the Room database. It was a androidX library. I didn't know a lot about libraries (I am a beginner) and also didn't know about AndroidX. I got these manifest merger errors and while resarching for a solution, I found out about the AndroidX libraries. So I wanted to migrate my project to AndroidX, but Android Studio can't resolve any of these libraries.
My build gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.financetracker.financetracker"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
def room_version = "2.1.0-alpha04"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
}
My build gradle(Project):
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.financetracker.financetracker">
<application
android:allowBackup="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".ui.activities.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.activities.HomeActivity" />
</application>
</manifest>
Try adding these in your project build.gradle file,
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
...
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
}
For Kotlin DSL
repositories {
maven { setUrl("https://maven.google.com") }
}
Related
I want to add admob to my app, but when I add buildscript and allprojects to file project-level build.gradleI get a message all buildscript {} blocks must appear before any plugins {} blocks in the script
project-level build.gradle :
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
google()
mavenCentral()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
build.gradle/app :
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.test"
minSdk 28
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-
rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:21.2.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.test">
<application
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.Test"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest>
Try This
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
remove buildscript {} and allprojects {} from project-level build.gradle,
latest version of Android Studio those code show in settings.gradle file, so no need to add those code inside project-level build.gradle
In my main Activity right after i try to initialize the two references it crashes, only to find out the error "FirebaseApp initialization unsuccessful"
private StorageReference mStorageReference;
private DatabaseReference mDatabaseReference;
mStorageReference = FirebaseStorage.getInstance().getReference("uploads");
mDatabaseReference = FirebaseDatabase.getInstance().getReference("uploads");
there is some code between the private declaration and the code itself, but that is not relevant to this problem
The manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firebase10">
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The build.gradle(Project):
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The build.gradle(app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.firebase10"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "com.google.android.gms:play-services-base:15.0.1"
api "com.google.android.gms:play-services-auth:16.0.0"
api "com.google.android.gms:play-services-identity:15.0.1"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:customtabs:28.0.0"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.gms:google-services:4.2.0'
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'
}
I set up everything with Tools-Firebase, and i know that the code looks like it is glued together, since it is. I've been going through threads and just added things but nothing worked. If this matters, i am running the app on my phone, not emulator.
Is your google-json file is well setted ?
Also Firebase needs time to connect to it server and gives you the instance referred to your device , give it some time or use a promise to make sure firebase is connected to it server and instance is generated, then perform the action that need firebase instance.
In build.gradle(Project) I Changed 'com.google.gms:google-services:4.1.0' To 'com.google.gms:google-services:4.2.0' and the problem is solved
This one here is non-sense, because that's a Gradle plugin:
dependencies {
implementation 'com.google.gms:google-services:4.2.0'
}
And this one belong to the bottom of the file:
apply plugin: 'com.google.gms.google-services'
The error says that "Error:Execution failed for task ':app:processDebugManifest'. > "
I have tried many solutions on this website but still, the problem is not solved. Please help me
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="project.myapp">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
android {
compileSdkVersion 28
defaultConfig {
applicationId "project.myapp"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
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'
implementation 'com.android.support:design:28.0.0'
// implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'com.firebaseui:firebase-ui-firestore:3.0.0'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
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'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(Project:myapp)
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
On Merged Manifest says that
Merging Errors: Error: tools:replace specified at line:5 for attribute
android:appComponentFactory, but no new value specified app main
manifest (this file), line 4 Error: Validation failed, exiting app
main manifest (this file)
For me, the solution was to just migrate to AndroidX.
On Android Studio, go to:
Refactor > Migrate to AndroidX
clean the project.
I.m delete this
tools:ignore="GoogleAppIndexingWarning",
tools:replace="android:appComponentFactory"
and fix this problem.good luck :)
Just remove the below line:
tools:replace="android:appComponentFactory"
And recompile and finally it works for me!
you should try this:
1:Remove tools:replace="android:appComponentFactory"
2:Provide new value for android:appComponentFactory" attribute
from:
Manifest merger failed, error on compiling
it worked for me!
solve my problem
Refactor > Migrate to AndroidX
In my case an error in Manifest file brought about this error at the time of generating apk although app was building flawlessly.
It was want of explicit 'exported' attribute in activity elements in Manifest file. after that apk too generated successfully .
I built my game via buildbox. My App kept crashing due to the error pasted below:
Fatal Exception: java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.zzd(android.content.Intent)"
at com.google.firebase.iid.zzc.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
at java.lang.Thread.run(Thread.java:760)
I fixed this error by putting the following command in AndroidManifext.xml:
<service android:name=".PTPlayer">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Now I am faced with a new crash reason:
Caused by: java.lang.ClassCastException: com.torsolutions.kawabachao.PTPlayer cannot be cast to android.app.Service
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3524)
at android.app.ActivityThread.-wrap4(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
My android level build gradle is:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
allprojects {
repositories {
google()
maven { url 'https://maven.google.com' }
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
and App level build gradle is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
signingConfigs {
config {
keyAlias 'upload'
keyPassword 'Hello#1986'
storeFile file('D:/kawakey/kawauploadkey/KawaUploadKey1.jks')
storePassword 'Hello#1986'
}
}
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.torsolutions.kawabachao"
minSdkVersion 19
targetSdkVersion 28
multiDexEnabled true
ndk {
moduleName "player_shared"
}
versionName '2.1'
versionCode 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
productFlavors {
}
}
dependencies {
implementation 'com.google.android.gms:play-services:+'
implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.android.gms:play-services-ads:17.1.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.android.gms:play-services-games:16.0.0'
implementation 'com.google.android.gms:play-services- identity:16.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
apply plugin: 'com.google.gms.google-services'
What I am faced with now is the App crashing within 30 minutes of launch. At times it doesn't crash for a few minutes but usually it crashes within the first minute. This has lead to a significant amount of uninstalls.
Would be grateful if someone can help. I have tried the solutions on the forum so far but no solutions yet.
After updating kotlin to RC-1036 i'm facing a weird issue: my code is not even compiled and packed.
When build passes and the app is launched i'm getting ClassNotFoundException: Didn't find class "example.myapplication.MainActivity".
I have tried to decompile apk with apktool and didn't find my classes inside the archive. There are no classes in build/intermediates dir either.
This is my project:
app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
buildscript {
ext.kotlin_version = '1.0.0-rc-1036'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "example.myapplication"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="example.myapplication"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
And MainActivity:
package example.myapplication
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
hello.text = "New text"
}
}
Build tools version is 2.0.0-beta2;
Might be something wrong with sourseSets, though nothing works if i try to reconfigure it somehow. Appreciate any help.
You should have both these plugins:
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
The first makes sure the Kotlin code compiles, the second is for the UI imports.