已解决-如何在Android上解决此编译问题?

时间:2020-03-27 16:07:36

标签: android android-layout

在过去的几天里,我的Android应用出现了问题。首先,它向我显示此错误:

    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

类文件:

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);
        }
    }

}

因此,我查看了Internet并尝试了给定的解决方案。我尝试了以下选项:Android Studio上的“无效的缓存并重新启动”,“同步gradle”和“文件同步”,我检查了所有资源,如果它没有无效的名称,或者它没有损坏,我看了看。此处提供的所有解决方案,以及其他帮助论坛,例如openclassroom(法语论坛)。然后,我尝试恢复gradle.build文件(在应用模块中),并且工作了一段时间。我只是删除了Firestore,这对我没有用,然后又开始混乱了。

因此,我查看了是否可以预览布局,首先没有。

它给了我这个错误:

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

我的Android清单:

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

我没有更多的解决方案,没有解决这个问题的想法,您有什么吗?

感谢您今后的回复!

1 个答案:

答案 0 :(得分:0)

已解决:

我放了旧版本的build.gradle文件,然后一点一点地我删除/更新了不同的实现,然后重新加载!感谢您的帮助。