2016-03-29 9 views
1

i Problem haben mit AppCompat und Gradle, erste Ausgabe ist meine App nur ein Gradle für Modul haben, und muss nicht Gradle für app wie das Bild zeige ich unter ich hatte 2 gradles in meinen anderen Anwendungen und wenn ihr wichtiges Projekt mit eclipse geschrieben wird, dann wanderte ich auf android Studio:erklärt android.support.v7.app in gradle

issue of having one gradle

und zweite ist, wenn ich eine meiner Aktivitäten laufen i den Fehler

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 

und hier ist mein Aktivitätscode whic Fehler verursachen:

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(); 
}} 

und mein gradle Inhalt auch hier ist:

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 { 
} 

i bereits appcompact für mein Projekt hinzugefügt, aber der Fehler denke ich, ist verwandtes irgendwie kompakt zu app.

+0

entfernen 'Modul:‚support-v4'' –

Antwort

0

Ihre Logcat wirft

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

Sie entfernen sollten module: 'support-v4'

Schließlich

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

Dann Clean-Rebuild-Sync Ihr Projekt.

Sie diese entfernen können, Keine Notwendigkeit

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

jetzt im diesem Fehler –

+0

Fehler beim Abruf: (44, 23) Fehler: kann nicht auf AlertDialog zugreifen Klassendatei für android.support.v7.app.AlertDialog nicht gefunden Fehler: Ausführung fehlgeschlagen für Task ': compileDebugJavaWithJavac'. > Kompilierung fehlgeschlagen; Weitere Informationen finden Sie in der Compilerfehlerausgabe. D: \ Android WorkSpace \ Flashlight Pro (Basis) \ src \ com \ soheil \ prolightfa \ color.java –

+0

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

0

die gesamte Abhängigkeits Ausschluss entfernen:

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' 
    //... 
} 

Anwendungsklasse:

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> 
Verwandte Themen