2016-03-29 7 views
1

のGradleでandroid.support.v7.app宣言は、最初の問題は、私のアプリはちょうど1 Gradleモジュール用を持っている、と私は私が持っていた の下に表示された画像のようなアプリをGradleを持っていませんその重要なプロジェクトは、Eclipseを使用して書かれている私の他のアプリではとIF 2 gradlesその後、私は、Android Studioに移行:私は私の活動のいずれかを実行したときに私は<code>AppCompat</code>と<code>Gradle</code>に問題がある

issue of having one gradle

2つ目は、私はエラーを取得している

03-29 12:15:30.461 18276-18276/com.soheil.prolightfa E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.soheil.prolightfa, PID: 18276 
java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14 
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:135) 
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:126) 
at android.support.v7.app.AppCompatDialog.getDelegate(AppCompatDialog.java:142) 
at android.support.v7.app.AppCompatDialog.<init>(AppCompatDialog.java:48) 
at android.support.v7.app.AlertDialog.<init>(AlertDialog.java:92) 
at android.support.v7.app.AlertDialog$Builder.create(AlertDialog.java:882) 
at com.flask.colorpicker.builder.ColorPickerDialogBuilder.build(ColorPickerDialogBuilder.java:223) 
at com.soheil.prolightfa.color.onCreate(color.java:43) 
at android.app.Activity.performCreate(Activity.java:6500) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3078) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3224) 
at android.app.ActivityThread.access$1000(ActivityThread.java:198) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1682) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6843) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199 

、ここで私の活動のコードwhic原因のエラーです:

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_color); 
    final ImageView imgbck= (ImageView) findViewById(R.id.imageView4); 
    ColorPickerDialogBuilder 
      .with(getApplicationContext()) 
      .setTitle("Choose color") 
      //.initialColor(currentBackgroundColor) 
      .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) 
      .density(12) 
      .setOnColorSelectedListener(new OnColorSelectedListener() { 
       @Override 
       public void onColorSelected(int selectedColor) { 
        // toast("onColorSelected: 0x" + Integer.toHexString(selectedColor)); 
       } 
      }) 
      .setPositiveButton("ok", new ColorPickerClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int selectedColor, Integer[] allColors) { 
        imgbck.setBackgroundColor(selectedColor); 
       } 
      }) 
      .setNegativeButton("cancel", new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, int which) { 
       } 
      }) 
      .build() 
      .show(); 
}} 

と私のGradle内容はここにもある:

allprojects { 
repositories { 
    maven { url "https://jitpack.io" } 
} 
} 
buildscript { 
repositories { 
    maven { url "https://jitpack.io" } 
    mavenCentral() 


} 
dependencies { 

    classpath 'com.android.tools.build:gradle:1.5.0' 
} 
} 
apply plugin: 'com.android.application' 
configurations { 
all*.exclude group: 'com.android.support', module: 'support-v4' 
} 
dependencies { 
compile 'com.github.QuadFlask:colorpicker:0.0.10' 

compile 'com.android.support:appcompat-v7:23.1.1' 

} 

android { 
compileSdkVersion 23 
buildToolsVersion '23.0.1' 
sourceSets { 
    main { 
     manifest.srcFile 'AndroidManifest.xml' 
     java.srcDirs = ['src'] 
     resources.srcDirs = ['src'] 
     aidl.srcDirs = ['src'] 
     renderscript.srcDirs = ['src'] 
     res.srcDirs = ['res'] 
     assets.srcDirs = ['assets'] 
    } 

    // Move the tests to tests/java, tests/res, etc... 
    instrumentTest.setRoot('tests') 

    // Move the build types to build-types/<type> 
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
    // This moves them out of them default location under src/<type>/... which would 
    // conflict with src/ being used by the main source set. 
    // Adding new build types or product flavors should be accompanied 
    // by a similar customization. 
    debug.setRoot('build-types/debug') 
    release.setRoot('build-types/release') 
} 
defaultConfig {} 
productFlavors { 
} 
buildTypes { 
} 

私はすでに私のプロジェクトのためのappcompactを追加しましたが、私が思うにエラーが関連しています何とかコンパクトにアプリに。

+0

削除 'モジュール:(44、23):「サポート-v4'' –

答えて

0

あなたのLogcatはあなたがmodule: 'support-v4'

最後に

configurations { 
     all*.exclude group: 'com.android.support' 
} 

その後Clean-Rebuild-Syncあなたのプロジェクトを削除する必要があります

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14 

をスローします。あなたはこれを削除することができます

不要

configurations { 
all*.exclude group: 'com.android.support', module: 'support-v4' 
} 
+0

今、このエラーに –

+0

エラーを取得イムエラー:AlertDialogにアクセスできません android.support.v7.app.AlertDialogのクラスファイルが見つかりません エラー: 'compileDebugJavaWithJavac'タスクの実行に失敗しました。 >コンパイルに失敗しました。詳細については、コンパイラのエラー出力を参照してください。 D:\ Android WorkSpace \ Flashlight Pro(ベース)\ src \ com \ soheil \ prolightfa \ color.java –

+0

@SoheilAfshari http://stackoverflow.com/questions/24998368/the-import-android-support-v7-cannot -be-resolved –

0

全体の依存関係の除外削除:

configurations { 
    all*.exclude group: 'com.android.support', module: 'support-v4' 
} 
0

build.gradle:

//... 
defaultConfig { 
    multiDexEnabled = true 
} 

dependencies { 
    //... 
    compile 'com.android.support:multidex:1.0.1' 
    //... 
} 

0123を

Applicationクラス:

public class App extends Application { 
    //... 
    @Override 
    protected void attachBaseContext(Context base) { 
     super.attachBaseContext(base); 
     MultiDex.install(this); 
    } 
    //... 
} 

のAndroidManifest.xml:

<application 
    android:name="com.company.App"> 
    <!-- ... --> 
</application> 
関連する問題