我正在使用android spring RestTemplate在我的应用程序上进行REST服务调用.我添加了android Instrumentation测试,其中包括模拟REST服务调用.从android studio运行时,我的所有测试运行正常,但测试无法在终端使用时加载spring mock类
./gradlew clean :app:connectedDebugAndroidTest
Run Code Online (Sandbox Code Playgroud)
spring.gradle上的spring测试依赖项
androidTestCompile("org.springframework:spring-test:3.2.8.RELEASE")
Run Code Online (Sandbox Code Playgroud)
如果我改为compile而不是androidTestCompile,Android测试从终端正常运行.由于我不希望这种依赖我的生产APK任何帮助,赞赏.
这是开始测试时的日志
08-05 00:04:12.585 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.asm.commons.JSRInlinerAdapter 08-05 00:04:12.587 22274-22302/com.libin .androiduitesting E/TestLoader:找不到类:org.springframework.asm.commons.TryCatchBlockSorter 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework. cglib.transform.AbstractProcessTask 08-05 00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.cglib.transform.AbstractTransformTask 08-05 00:04:12.603 22274- 22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.core.convert.support.ConvertingPropertyEditorAdapter 08-05 00:04:12.610 22274-22302/com.libin.androiduitesting E/TestLoader:无法find class:org.springframework.core.io.ResourceEditor 08-05 00:04:12.611 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.spring framework.core.io.support.ResourceArrayPropertyEditor 08-05 00:04:12.617 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.MockHttpInputMessage 08-05 00:04 :12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.MockHttpOutputMessage 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http.client.MockClientHttpRequest 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.http. client.MockClientHttpResponse 08-05 00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.jndi.ExpectedLookupTemplate 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader:找不到类:org.springframework.mock.jndi.SimpleNamingContext 08-05 00:04:12.619 22274-22302/com.libin.androiduitesting …
android spring-test android-espresso spring-android android-instrumentation
我有一些drawables要选择的View.当用户drawable在应用程序启动时选择其中一个和下一个时,我必须只显示所选的drawable.
是否可以存储Resource ID共享首选项并在Resource ID下次启动应用程序时检索所选的drawable .
我知道这可能在此之前讨论过.但我仍然感到困惑,如果我getApplicationContext()用来显示一个Dialog.
我有一个getApplicationContext()用于创建 AlertDialog.Builder的应用程序,当显示对话框时应用程序崩溃.但是,如果我使用SomeActivity.this上下文它工作正常.
注意:这个应用程序现在已经在Play商店中运行了一段时间,之前正在运行,但不确定从哪个Android版本崩溃.
崩溃堆栈跟踪
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
at android.view.ViewRootImpl.setView(ViewRootImpl.java:540)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:286)
at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
import android.app.Fragment;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.widget.TextView;
public class MainFragment extends Fragment {
protected AlphaAnimation fadeIn = new AlphaAnimation(0.0f , 1.0f );
public MainFragment(){}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.main_fragment, container, false);
String fontPath = "fonts/roboto.ttf";
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), fontPath);
TextView txt1 = (TextView) rootView.findViewById(R.id.headerTextView);
txt1.setTypeface(font);
TextView txt2 = (TextView) rootView.findViewById(R.id.instructions);
txt2.setTypeface(font);
txt1.startAnimation(fadeIn);
txt2.startAnimation(fadeIn);
fadeIn.setDuration(1400);
fadeIn.setFillAfter(true);
Rect rectangle = new …Run Code Online (Sandbox Code Playgroud)