'How to fix this compilation problem on Android?
For the past few days, I have had a problem with my Android app. First it shows me this error:
F:\DataHosting\ApplicationV2\app\src\main\java\fr\ph1823\datahosting\MaintenanceActivity.java:16: error: cannot find symbol
setContentView(R.layout.activity_maintenance);
^
symbol: variable layout
Class file:
package fr.ph1823.datahosting;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.ImageView;
public class MaintenanceActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maintenance);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if(extras != null) {
ImageView img = findViewById(R.id.maintenanceImg);
if(extras.get("old") != null)
img.setImageResource(R.drawable.old);
else if(extras.get("error") != null)
img.setImageResource(R.drawable.error);
}
}
}
So I looked on the internet and tried the given solution. I tried the following options: "invalid cache and restart", "synchronize gradle" and "file synchronization" on Android Studio, I checked all the resources, if it did not have an invalid name, or if it was not corrupt, I looked at all the solutions given on here, and other help forums like openclassroom (French forum). Then I tried to restore my gradle.build file (in the app module), and it worked, for a while. I just removed firestore, which was not useful to me, and it started messing around again.
So I looked to see if the preview of a layout was possible, first of all not.
It gives me this error:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "fr.ph1823.datahosting"
minSdkVersion 19
targetSdkVersion 29
versionCode 19
versionName "Bêta 1.3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
resConfigs ''// add this to enable multi-dex
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion = '29.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat-resources:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta4"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-base:17.2.0'
implementation 'com.google.android.gms:play-services-ads:19.0.1'
implementation 'com.google.firebase:firebase-ads:19.0.1'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-firestore:21.4.1'
//CMP Conset
implementation 'com.google.android.ads.consent:consent-library:1.0.8'
//5d02668acf7fcd0018c24d25
//compile 'com.github.vungle:vungle-android-sdk:6.2.5'
// Vungle SDK
implementation 'com.google.ads.mediation:vungle:6.4.11.1'
//AdCollony
implementation 'com.adcolony:sdk:4.1.0'
implementation 'com.google.ads.mediation:adcolony:4.1.0.0'
//TapJoy
api 'com.tapjoy:tapjoy-android-sdk:12.4.2@aar'
implementation 'com.google.ads.mediation:tapjoy:12.4.2.0'
//MoPub
/* implementation('com.mopub:mopub-sdk:@aar') {
transitive = true
}*/
implementation 'com.google.ads.mediation:mopub:5.11.1.0'
//AppLovin
implementation "com.applovin:applovin-sdk:9.8.0"
implementation 'com.google.ads.mediation:applovin:9.8.0.0'
//InMobi
implementation 'com.inmobi.monetization:inmobi-ads:9.0.1'
implementation 'com.google.ads.mediation:inmobi:7.3.0.0'
//IronSource
implementation 'com.ironsource.sdk:mediationsdk:6.15.0.1@jar'
implementation 'com.google.ads.mediation:ironsource:6.14.0.1.0'
// Optional Google Play Services - Location and Basement
implementation 'com.google.android.gms:play-services-basement:17.2.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
//Chart boost
implementation 'com.chartboost:chartboost-sdk:8.0.2'
implementation 'com.google.ads.mediation:chartboost:8.0.1.0'
//FaceBook
//Audience Network SDK
implementation 'com.facebook.android:audience-network-sdk:5.7.1'
implementation 'com.facebook.android:facebook-android-sdk:6.3.0'
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
My Android 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="fr.ph1823.datahosting">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission
android:name="android.permission.AUTHENTICATE_ACCOUNTS"
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:roundIcon="@drawable/logo"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:fullBackupContent"
tools:ignore="LockedOrientationActivity">
<activity
android:name=".MaintenanceActivity"
android:label="@string/title_activity_maintenance"
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".SplashScreen"
android:configChanges="orientation"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="datahosting.fr"
android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:configChanges="orientation"
android:label="@string/title_activity_settings"
android:screenOrientation="portrait" />
<activity
android:name=".Main2Activity"
android:configChanges="orientation"
android:label="@string/app_name"
android:screenOrientation="fullSensor" />
<activity
android:name=".login.LoginActivity"
android:configChanges="orientation"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<service android:name=".accounts.DataAccount">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<!--
***********
ADS XML INF
***********
-->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1370634603527309~1700079071" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="applovin.sdk.key"
android:value="fGO2RFzfUTPAFNa9_w3dvUBtEgvMmB9uo4EN1mmI__B773STBxCsfTSl38atJGxwi6U4_fL6wQ47LaVH1-bV6U" />
<!--
<service android:name="p021fr.ph1823.datahosting.service.NotificationFireBaseMessaging" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.google.firebase.messaging.FirebaseMessagingService" android:exported="false">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service> !
-->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:exported="false" />
<activity
android:name="com.ironsource.sdk.controller.ControllerActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true" />
<activity
android:name="com.ironsource.sdk.controller.InterstitialActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" />
<activity
android:name="com.ironsource.sdk.controller.OpenUrlActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" />
<provider
android:name="com.google.android.gms.ads.MobileAdsInitProvider"
android:authorities="fr.ph1823.datahosting.mobileadsinitprovider"
android:exported="false"
android:initOrder="100" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false" />
<service
android:name="com.google.android.gms.measurement.AppMeasurementJobService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<!-- <service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:exported="false">
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</receiver>
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="fr.ph1823.datahosting.firebaseinitprovider"
android:exported="false"
android:initOrder="100" /> !-->
<activity
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:exported="false" />
<activity
android:name="com.tapjoy.TJAdUnitActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="com.tapjoy.TJContentActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity android:name="com.chartboost.sdk.CBImpressionActivity"
android:excludeFromRecents="true"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:configChanges="keyboardHidden|orientation|screenSize" />
</application>
</manifest>
I have no more solution, no idea to solve this problem, do you have any?
Solution 1:[1]
Solved:
I put an old version of the build.gradle file, then little by little I remove / update the different implementation, and it reloads! Thanks for helping me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ph1823 |