2017-10-09 70 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'