Android Studio + Gradle新手.
我正在尝试使用以下命令从命令行运行我的应用程序:
gradlew installDebug
Run Code Online (Sandbox Code Playgroud)
只有在我刚打开Studio时执行该命令并执行初始同步/构建操作时,应用程序才会安装在我的设备上.
每当我修改我的代码,并尝试再次运行该命令时,构建失败并显示以下错误:
Execution failed for task ':app:compileDebugJavaWithJavac'
> Could not find tools.jar
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?提前致谢.
Flutter 的新手。
我正在制作一个应用程序,它有一个初始屏幕,当用户打开应用程序时它最初会显示出来。3 秒后,应用程序将显示登录或仪表板屏幕,具体取决于身份验证状态。
这是我的代码。
main.dart
void main() {
runApp(myApp);
}
MaterialApp myApp = MaterialApp(
initialRoute: "/",
routes: {
"/": (context) => SplashScreen(),
"/signin": (context) => SignInScreen(),
"/notes": (context) => NotesScreen(),
},
);
Run Code Online (Sandbox Code Playgroud)
飞溅屏幕.dart
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
@override
void initState() {
super.initState();
_goToNextScreen();
}
void _goToNextScreen() {
Future.delayed(
Duration(seconds:3),
() async {
AuthState authState = await Auth.getAuthState();
String route = authState == AuthState.SIGNED_IN ? "/notes" : "/signin"; …Run Code Online (Sandbox Code Playgroud) 目前试图通过使用这个类来做到这一点:
public class EqualItemSpacingDecoration extends RecyclerView.ItemDecoration {
private int space;
public EqualItemSpacingDecoration(int space) {
this.space = space;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.bottom = space;
if (parent.getChildLayoutPosition(view) < 2)
outRect.top = space;
if (parent.getChildLayoutPosition(view) % 2 == 0) {
outRect.left = space;
outRect.right = space / 2;
} else {
outRect.left = space / 2;
outRect.right = space;
}
}
}
Run Code Online (Sandbox Code Playgroud)
并将其与以下代码一起使用:
recycler.addItemDecoration(new EqualItemSpacingDecoration(12));
Run Code Online (Sandbox Code Playgroud)
我将如何解决这个问题?
我的应用程序集成了Firebase身份验证。一切似乎都很好,直到我注意到打开应用程序的问题,即使已经有用户登录,它也会显示登录屏幕。
退出应用程序并再次启动它可以解决问题(应用程序不再要求用户再次登录),尽管它为用户带来了非常糟糕的体验。
我已经阅读了文档,并且很明显,FirebaseAuth.getInstance().getCurrentUser()如果auth尚未完成初始化,则调用可能返回null。我假设这就是问题发生的原因。因此,我想知道是否有一种方法可以等待FirebaseAuth完成其初始化,然后才能调用getCurrentUser()?
我希望实现这样的目标:

但这是我尝试后得到的:

我已经将项目布局的高度设置为WRAP_CONTENT,但结果仍然相同.
我该怎么办?