2017-10-09 69 views
1

改变的build.gradle依赖于相关的更改对于奥利奥提供错误

compile 'com.android.support:design:26.1.0' 

后提到here,成功生成该项目,但是当我尝试运行它给了这样的错误

error: cannot find symbol variable super

error: cannot find symbol method findViewById(int)

error: cannot find symbol method finish()

error: cannot find symbol method getResources()

error: cannot find symbol method setContentView(int)

build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "26.0.2" 
    defaultConfig { 
     applicationId "com.example.myApp" 
     minSdkVersion 16 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    android { 
     useLibrary 'org.apache.http.legacy' 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.1' 
    compile fileTree(dir: 'libs', include: ['*.jar']) 


    testCompile 'junit:junit:4.12' 

    compile 'com.android.support:design:26.1.0' 
    compile 'com.android.support:support-v4:25.3.1' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    } 
allprojects { 
    repositories { 
     jcenter() 
     maven { 
      url 'https://maven.google.com' 
     } 
     maven { url "https://jitpack.io" } 
    } 
} 
+1

如何更新其他两个支持库'support-v4'和'cardview-v7'到'26.1.0'并执行清理构建? – pleft

+0

也改变这两个库编译'com.android.support:support-v13:26.1.0'并编译'com.android.support:cardview-v7:26.1.0',但错误保持不变。 –

+0

你干净了吗? – pleft

回答

2

更改我的依赖后,问题解决。

compile 'com.android.support:design:26.1.0' 
compile 'com.android.support:support-v13:26.1.0' 
compile 'com.android.support:appcompat-v7:26.1.0' 
compile 'com.android.support:cardview-v7:26.1.0' 

并且构建版本如下所示。

compileSdkVersion 26 
    buildToolsVersion "26.0.2" 
    defaultConfig { 
     minSdkVersion 16 
     targetSdkVersion 26 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 

该问题是由于ActionbarActivity。我有一些扩展了ActionbarActivity的活动。 所以刚刚取代Actioncom活动Appcompact活动。

请注意: android开发者文档说:“更新了AppCompatActivity作为使用支持库动作栏功能的活动的基类,该类替换了弃用的ActionBarActivity。”

0

java你的模块文件夹中创建新类:
包装结构:

的Java/ 的Android /支持/ V7 /应用/

package android.support.v7.app; 

public class ActionBarActivity extends AppCompatActivity { 
} 

加入项目级别构建以下。 gradle:

defaultConfig { 
     multiDexEnabled true 

} 

内部依存关系:

compile 'com.android.support:multidex:1.0.1'