Android Studio update (1.5 to 2.2.3) breaks project

我的梦境 提交于 2019-12-12 04:35:37

问题


So i've updated my Android Studio from Version 1.5 to 2.2.3 and this completely broke my project. I'm pretty new at programming and my app worked just fine before, but now, every single android library import is marked red.

import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.CountDownTimer;

for example, none of these are recognized any more. I've updated everything Android Studio wanted me to, but tbh i don't know how to fix this.

My gradle file looks like the following:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.privatpc.quiztest"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    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'

}

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Update: Doing File-> "Invalidate Caches/Restart" seemed to work. Now the next Problem is the following:

Once i try running the project the app opens and immediately crashes. I get the following log:

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

回答1:


Try doing this in build.gradle

buildscript {repositories {jcenter()}dependencies {classpath 'com.android.tools.build:gradle:2.2.3'}}




回答2:


If you are trying on devices below Android 7, generate APK by using V1 signature instead of V2. All apps will crash if you select V2 Signature because it is targeting for Android 7.

signature



来源:https://stackoverflow.com/questions/42299065/android-studio-update-1-5-to-2-2-3-breaks-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!