什么是ScannerKotlin中的Java ?
我用过readLine()但我想知道它的类型是否安全?
我从https://developers.google.com/+/mobile/android/getting-started学习了google plus登录
当我启动我的应用程序时,有一个Toast消息"用户已连接!" 然后我按下G +登录按钮我的应用程序强制关闭.
这是logcat的消息形式
04-08 18:31:21.680 24231-24231/app.umitems.test.testgoogleplus1.app D/? onClick()
04-08 18:31:21.680 24231-24231/app.umitems.test.testgoogleplus1.app D/AndroidRuntime? Shutting down VM
04-08 18:31:21.680 24231-24231/app.umitems.test.testgoogleplus1.app W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x41f99ce0)
04-08 18:31:21.685 24231-24231/app.umitems.test.testgoogleplus1.app E/AndroidRuntime? FATAL EXCEPTION: main
Process: app.umitems.test.testgoogleplus1.app, PID: 24231
java.lang.NullPointerException
at app.umitems.test.testgoogleplus1.app.ExampleActivity.resolveSignInError(ExampleActivity.java:68)
at app.umitems.test.testgoogleplus1.app.ExampleActivity.onClick(ExampleActivity.java:166)
at com.google.android.gms.common.SignInButton.onClick(Unknown Source)
at android.view.View.performClick(View.java:4445)
at android.view.View$PerformClick.run(View.java:18446)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5081)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
这是我的代码
package app.umitems.test.testgoogleplus1.app;
import android.app.Activity;
import …Run Code Online (Sandbox Code Playgroud) 我Android Studio今天没有工作。当我构建我的项目并同步它时,它说:Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
我没有更改项目中的任何内容,项目的语言是Kotin. 我使用JDK 13和Android Studio 3.6.1和最新的Android SDK。
我尝试使用 Hilt codelab https://codelabs.developers.google.com/codelabs/android-hilt#10
它与 Activity 和 Fragment 配合良好
记录器是 RoomDB
然后我尝试用这篇文章将记录器注入到 viewModel 中
通过添加
implementation "androidx.hilt:hilt-lifecycle-viewmodel
:1.0.0-alpha02"
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
Run Code Online (Sandbox Code Playgroud)
查看模型代码
class RecordFragmentViewModel @ViewModelInject constructor(@Assisted private val savedStateHandle: SavedStateHandle) :
ViewModel() {
@DatabaseLogger
@Inject
lateinit var logger: LoggerDataSource
Run Code Online (Sandbox Code Playgroud)
要注入的类记录器
class LoggerLocalDataSource
@Inject constructor(private val logDao: LogDao) : LoggerDataSource {
Run Code Online (Sandbox Code Playgroud)
日志记录模块
@Qualifier
annotation class InMemoryLogger
@Qualifier
annotation class DatabaseLogger
@InstallIn(ApplicationComponent::class)
@Module
abstract class LoggingDatabaseModule {
@DatabaseLogger
@Singleton
@Binds
abstract fun bindDatabaseLogger(impl: LoggerLocalDataSource): LoggerDataSource
}
@InstallIn(ActivityComponent::class)
@Module
abstract class LoggingInMemoryModule { …Run Code Online (Sandbox Code Playgroud) 这是我的代码
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ChangeTextBehaviorTest {
public static final String STRING_TO_BE_TYPED = "Espresso";
@Rule
public ActivityTestRule<LandingActivity> mActivityRule = new ActivityTestRule<> (
LandingActivity.class );
@Test
public
void changeText_sameActivity () {
String testText = "testText";
onView ( withId ( R.id.action_a) )
.perform ( click (), closeSoftKeyboard () );
onView ( withHint ( R.string.add_list ) ).perform ( typeTextIntoFocusedView ( testText ) );
onView ( withText ("ADD" ) ).perform ( click () );
}
Run Code Online (Sandbox Code Playgroud)
首先我需要点击floatingButton来打开MaterialDialog
然后我尝试通过它的提示访问 editText 引用
onView ( withHint ( R.string.add_list …Run Code Online (Sandbox Code Playgroud) 该测试不起作用
assertThat(bundle.getMyObj(), equalTo(Optional.absent()));
Run Code Online (Sandbox Code Playgroud)
一开始我只是使用一个普通的对象。(尚未使用可选<>)
private MyObj myObj;
Run Code Online (Sandbox Code Playgroud)
测试将如下所示
assertThat(myBundle.getMyObj(), nullValue());
Run Code Online (Sandbox Code Playgroud)
我将 myObj 更改为
private Optional<MyObj> myObj = Optional.absent();
Run Code Online (Sandbox Code Playgroud)
然后我将测试更改为
assertThat(bundle.getTracking(), equalTo(Optional.absent()));
Run Code Online (Sandbox Code Playgroud)
然后我得到一个错误
java.lang.AssertionError:
Expected: <Optional.absent()>
but: was <Optional.of(com.my.package.MyObj@2a9627bc)>
Expected :<Optional.absent()>
Actual :<Optional.of(com.my.package.MyObj@2a9627bc)>
Run Code Online (Sandbox Code Playgroud)
我也尝试了下面的代码,但出现编译错误
assertThat(myBundle.getMyObj(), equalTo(Optional.of(MyObj)));
Run Code Online (Sandbox Code Playgroud) 我的意思是gSuite 附带的Google Chat
已经在https://support.google.com/hangouts/answer/3112001?co=GENIE.Platform%3DDesktop&hl=en 上找到答案,但没有得到任何答案。
android android-layout android-toolbar android-design-library
我通常使用Git Fetch从服务器获取最新信息。Git Fetch不会更改代码库,也不会花费太多时间和网络流量。所以当我上厕所或做其他事情时,自动做会很好Git Fetch。有没有办法做这样的事情?
我运行下面的代码并返回任何错误();
error: incompatible types
required: Matcher <View>
found: Matcher <Object>
/**
* Perform action of waiting until UI thread is free. <p/> E.g.: onView(isRoot()).perform(waitUntilIdle());
* @return
*/
public static ViewAction waitUntilIdle(){
return new ViewAction(){
@Override public Matcher<View> getConstraints(){
return anything();
}
@Override public String getDescription(){
return "wait until UI thread is free";
}
@Override public void perform( final UiController uiController, final View view){
uiController.loopMainThreadUntilIdle();
}
}
;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
android ×7
java ×3
testing ×2
chat ×1
dagger-hilt ×1
git ×1
google-chat ×1
google-plus ×1
gradle ×1
guava ×1
ide ×1
input ×1
java-11 ×1
kotlin ×1
unit-testing ×1