问题描述
所以我已经将Android Studio从版本1.5更新到了2.2.3,这完全破坏了我的项目.我在编程方面还很新,我的应用以前也能很好地工作,但是现在,每一个android库导入都标记为红色.
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;
例如,这些都不再被识别.我已经更新了Android Studio想要我执行的所有操作,但是我不知道如何解决此问题.
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.
我的gradle文件如下所示:
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
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.
推荐答案
尝试在build.gradle中完成此操作
Try doing this in build.gradle
buildscript {存储库{jcenter()}依赖项{classpath'com.android.tools.build:gradle:2.2.3'}}
buildscript {repositories {jcenter()}dependencies {classpath 'com.android.tools.build:gradle:2.2.3'}}
这篇关于Android Studio更新(1.5至2.2.3)中断了项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!