4

私は自分のアプリケーションのためのloginfacebookを追加しようとしています。しかし、私がこれを行う際に必要なリポジトリを追加したとき。エラーが発生しました。 AndroidJUnit4は今解決できません。シンボルを解決できませんAndroidJUnit4

ExampleInstrumentedTest.java

package com.example.user.enyatravelbataan; 

import android.content.Context; 
import android.support.test.InstrumentationRegistry; 
import android.support.test.runner.AndroidJUnit4; 

import org.junit.Test; 
import org.junit.runner.RunWith; 

import static junit.framework.Assert.assertEquals; 
import static org.junit.Assert.*; 

/** 
* Instrumentation test, which will execute on an Android device. 
* 
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> 
*/ 
@RunWith(AndroidJUnit4.class) 
public class ExampleInstrumentedTest { 
@Test 
public void useAppContext() throws Exception { 
    // Context of the app under test. 
    Context appContext = InstrumentationRegistry.getTargetContext(); 

    assertEquals("com.example.user.enyatravelbataan", 
appContext.getPackageName()); 
} 
} 


apply plugin: 'com.android.application' 

と、これは私のビルドです:Gradleの(アプリ)

android { 
compileSdkVersion 24 
buildToolsVersion "24.0.3" 
useLibrary 'org.apache.http.legacy' 


repositories { 
    mavenCentral() 
} 

defaultConfig { 
    applicationId "com.example.user.enyatravelbataan" 
    minSdkVersion 16 
    targetSdkVersion 24 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile(name: 'wikitudesdk', ext: 'aar') 
// compile 'org.apache.httpcomponents:httpclient:4.5' 
// compile 'org.apache.httpcomponents:httpcore:4.4.1' 
compile files('libs/MD5Simply.jar') 
compile files('libs/GenAsync.1.2.jar') 
compile 'com.facebook.android:facebook-android-sdk:[4,5)' 
compile 'com.android.support:appcompat-v7:24.2.1' 
compile 'com.android.support:multidex:1.0.0' 
compile 'com.google.android.gms:play-services:9.8.0' 
compile 'com.google.android.gms:play-services-location:9.8.0' 
compile 'com.google.android.gms:play-services-appindexing:9.8.0' 
compile 'com.android.support:cardview-v7:24.2.1' 
compile 'com.squareup.picasso:picasso:2.5.2' 
compile 'com.android.support:design:24.2.1' 
compile 'com.android.volley:volley:1.0.0' 
compile 'com.android.support:support-v4:24.2.1' 

testCompile 'junit:junit:4.12' 
} 

repositories { 
flatDir { 
    dirs 'libs' 
} 
} 
apply plugin: 'com.google.gms.google-services' 

答えて

4

androidTestCompile 'com.android.support:support-annotations:23.1.0' 
androidTestCompile 'com.android.support.test:runner:0.4.1' 
androidTestCompile 'com.android.support.test:rules:0.4.1' 
を試してみてください上記の次の追加セクション

の依存関係私は壁に頭を強打して、および/または任意のオブジェクトは、私は私のSQLiteの機能部を作るために私の前に見

:上記の回答に加えて

configurations.all { 
    resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' 
} 
+0

私は試しましたが、エラーが表示されます。警告:依存関係との競合 'com.android.support:support-annotations'。 app(25.0.0)とtest app(23.1.1)の解決されたバージョンが異なります。詳細はhttp://g.co/androidstudio/app-test-app-conflictをご覧ください。 –

+0

答えが更新されました。 http://stackoverflow.com/questions/33317555/conflict-with-dependency-com-android-supportsupport-annotations-resolved-ver – Pehlaj

+0

これは今動作します。ありがとうございました :) –

0

あなたは厳密に次の手順に従って確認してくださいテストされた。私が何をしていても、インターネット上の多くの賢明な人々がどのように厳格に提案に従うかは、うまくいかなかった。

私は就学前に行き、私の愚かな間違いを実現するためにやり直さなければならなかった。 AndroidJUnit4はInstrumentation Testでのみ使用でき、JUnitはローカルテストに使用する必要があることを知りました。つまり、フォルダはsrc/androidTest/javaである必要があります。私はandroidTestフォルダの下に直接私のテストクラスを持っていたので、私はその厄介なエラーに直面しなければならなかった。しかし、私がsrc/androidTest/javaの下に移動した瞬間、すべてが「」のように非常に明確になりました。現在、雨が降っています。 "言う

Take a look at this article ...

Run Instrumented Unit Tests To run your instrumented tests, follow these steps:

Be sure your project is synchronized with Gradle by clicking Sync Project in the toolbar. Run your test in one of the following ways: To run a single test, open the Project window, and then right-click a test and click Run . To test all methods in a class, right-click a class or method in the test file and click Run . To run all tests in a directory, right-click on the directory and select Run tests . The Android Plugin for Gradle compiles the instrumented test code located in the default directory (src/androidTest/java/), builds a test APK and production APK, installs both APKs on the connected device or emulator, and runs the tests. Android Studio then displays the results of the instrumented test execution in the Run window.

そこで人々は、計装テスト用フォルダが

src/androidTest/java

地元のテストのために(ケースを忘れてはいけない)でなければなりませんフォルダは

である必要があります10

src/test/java

あなたは、あなたのパッケージフォルダ(複数可)と一致するようにアプリのパッケージ

希望を持つことができ、これは、コミュニティのために役立ちます!

関連する問題