2017-11-01 16 views
1

Android Studio 3.0へのアップグレード後も、私はまだそのバックアップを保持していますが、プロジェクトも更新されています。私は実験的なgradleプラグインの非常に初期のバージョンからバージョン3.0.0にアップグレードしていくつもりですが、これは私が多くの問題を抱えています。gradle-experimentalからのGradle 3.0.0のアップグレード:0.9.3のエラー

トップレベルのグラデルファイルは、まったく問題ないと思います。

buildscript { 
    repositories { 
     google() 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0' 
     //classpath 'com.android.tools.build:gradle-experimental:0.9.3' 
    } 
} 

allprojects { 
    repositories { 
     google() 
     jcenter() 
    } 
} 

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

アプリのgradleビルドファイルは、私が変更を反映しているものです。これは、現在およそcppFlagsエラーとの文句:

Error:(25, 0) Could not find method cppFlags() for arguments [-std=c++11, -fexceptions, -Isrc/main/android/armeabi-v7a/include, -frtti, -O2] on object of type com.android.build.gradle.internal.dsl.NdkOptions.

これまでのGradleファイルへの変更は次のとおりです。

//apply plugin: 'com.android.model.application' 
apply plugin: 'com.android.application' 

//model { 
    android { 
     buildToolsVersion "26.0.2" 
     compileSdkVersion 23 

     defaultConfig { 
      minSdkVersion 19 
      targetSdkVersion 19 

      ndk { 
       def ffmpeg = "src/main/android/armeabi-v7a/include" 

       moduleName = "ffplayer3jni" 

       ldLibs "log", "android", "GLESv2", "dl", "EGL", "z", 
         "stdc++", "OpenSLES" 

       //cppFlags.addAll("-std=c++11", "-fexceptions", '-I'+file(ffmpeg), 
       //  "-D __cplusplus=201103L", "-frtti", 
       //  "-D __GXX_EXPERIMENTAL_CXX0X__", "-O2") 

       cppFlags "-std=c++11", "-fexceptions", "-I${ffmpeg}", "-frtti", "-O2" 

       stl "gnustl_static" 

       //abiFilters.addAll("armeabi-v7a") 
       abiFilters "armeabi-v7a" 
      } 
     } 
    } 

    android.buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles.add(file('proguard-rules.pro')) 
     } 
    } 

    repositories { 
     def loc = "src/main/jniLibs/armeabi-v7a/" 

     libs(PrebuiltLibraries) { 

      libavutil { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavutil.so") 
       } 
      } 

      libavcodec { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavcodec.so") 
       } 
      } 

      libavformat { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavformat.so") 
       } 
      } 

      libavfilter { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavfilter.so") 
       } 
      } 

      libpostproc { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libpostproc.so") 
       } 
      } 

      libswresample { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libswresample.so") 
       } 
      } 

      libswscale { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libswscale.so") 
       } 
      } 
     } 
    } 

    android.sources { 
     main { 
      jni { 
       dependencies { 
        library "libavformat" linkage "shared" 
        library "libavcodec" linkage "shared" 
        library "libavfilter" linkage "shared" 
        library "libavutil" linkage "shared" 
        library "libswscale" linkage "shared" 
        library "libswresample" linkage "shared" 
        library "libpostproc" linkage "shared" 
       } 
      } 
     } 
    } 
//} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
} 

元のGradleのファイルはまだそれを使用していたにもかかわらず、Androidのメーカー2.3で働いていました古い実験的なプラグイン。このファイルは/された次のとおりです。

apply plugin: 'com.android.model.application' 

model { 
    android { 
     def ffmpeg = "src/main/android/armeabi-v7a/include" 

     buildToolsVersion "25.0.3" 
     compileSdkVersion 25 

     defaultConfig.with { 
      minSdkVersion.apiLevel = 19 
     } 

     ndk { 
      moduleName = "ffplayer3jni" 

      ldLibs.addAll("log", "android", "GLESv2", "dl", "atomic", "EGL", 
        "z", "stdc++", "OpenSLES") 

      cppFlags.addAll("-std=c++11", "-fexceptions", '-I'+file(ffmpeg), 
        "-D __cplusplus=201103L", "-frtti", 
        "-D __GXX_EXPERIMENTAL_CXX0X__", "-O2") 
      CFlags.add('-I'+file(ffmpeg)) 

      stl = "gnustl_static" 
      //stl = "stlport_shared" 

      abiFilters.addAll("armeabi-v7a") 
     } 
    } 

    android.buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles.add(file('proguard-android.txt')) 
     } 
    } 

    repositories { 
     def loc = "src/main/jniLibs/armeabi-v7a/" 

     libs(PrebuiltLibraries) { 

      libavutil { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavutil.so") 
       } 
      } 

      libavcodec { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavcodec.so") 
       } 
      } 

      libavformat { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavformat.so") 
       } 
      } 

      libavfilter { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libavfilter.so") 
       } 
      } 

      libpostproc { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libpostproc.so") 
       } 
      } 

      libswresample { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libswresample.so") 
       } 
      } 

      libswscale { 
       binaries.withType(SharedLibraryBinary) { 
        sharedLibraryFile = file(loc + "libswscale.so") 
       } 
      } 
     } 
    } 

    android.sources { 
     main { 
      jni { 
       dependencies { 
        library "libavformat" linkage "shared" 
        library "libavcodec" linkage "shared" 
        library "libavfilter" linkage "shared" 
        library "libavutil" linkage "shared" 
        library "libswscale" linkage "shared" 
        library "libswresample" linkage "shared" 
        library "libpostproc" linkage "shared" 
       } 
      } 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
} 

だから私の質問は、私は、このプロジェクトは、Android Studioの3.0の新しいのGradleプラグインで作業を取得するために作成する必要がありますどのような変更、ありますか?

ご覧のとおり、いくつかの変更を加えました。セクションを移動し、オプションを変更して最終的にgradleスクリプトを取得しましたが、今は非常に固執しています。

編集:私は最終的にあきらめて、Android Studio 3.0.1で最初から新しいプロジェクトを作成しました。多くのグーグル・グーグルでは、ネイティブ・コード、ffmpegライブラリー、正しいビルドをすべて手に入れました。

+0

次のようでしたか。http://tools.android.com/tech-docs/new-build-system/gradle-experimental/migrate-to-stable? – Yashasvi

+1

これは、2.3から新しいビルドシステムへのアップグレードの概要を示しています。私は0.9.3から3.0.0に向かいます。私はずっと前に消極的であったために失敗しました。新しいプロジェクトを作成し、すべてをコピーすることを検討してください。 – WLGfx

答えて

0

I gave up in the end and created a new project from scratch in Android Studio 3.0.1. After much googling I managed to get all the native code, ffmpeg libraries and correct builds done.

右の実験プラグインの概念は非常に異なります。 Groovyベースの新しいビルドシステムを導入しようとしました。ここでは、ネイティブライブラリを構築するために確立されたツール - cmakeまたはAndroid.mkを使用します。

関連する問題