如果我将具有Android Oreo OS的android手机连接到Linux PC,则会收到以下错误日志
$ adb devices
List of devices attached
xxxxxxxx no permissions (user in plugdev group; are your udev rules wrong?);
see [http://developer.android.com/tools/device.html]
Run Code Online (Sandbox Code Playgroud)
我尝试使用错误消息提供的链接,但仍然收到相同的错误。
Firebase auth工作正常,调试版本突然开始失败,没有任何代码更改,记录下面的消息
D/PhoneAuthActivity(7392):signInWithCredential:failure:com.google.firebase.auth.FirebaseAuthException:此应用无权使用Firebase身份验证.请验证Firebase控制台中是否配置了正确的软件包名称和SHA-1.[应用验证失败].
成功登录和失败之间唯一值得注意的行动是android studio升级.
java android firebase android-studio firebase-authentication
我有一个使用firebase和firebase auth ui库的项目.问题是我无法使用Google登录登录,当我尝试加载一两秒钟然后只显示一个Toast消息"Developer Error".我可以用电子邮件和密码登录就好了.这只是签名apks的一个问题,当我调试Google时,登录工作正常.
在我的proguard-rules.pro中,我将minifyEnabled设置为false.
我已将SHA-1添加到我的firebase项目并已下载正确的json文件.
来自app level build.gradle的依赖块
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
这是我的AuthStateListener
mAuthStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
signedInInitialized();
} else {
signedOutCleanUp();
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.FirebaseSignInTheme)
.setIsSmartLockEnabled(false)
.setAvailableProviders(
Arrays.asList(new …Run Code Online (Sandbox Code Playgroud) 也许这是一个愚蠢的问题,但是想要收集应用程序对库的依赖.(所以我可以轻松管理所有依赖项的版本)
应用程序/的build.gradle
api project(path: ':library')
Run Code Online (Sandbox Code Playgroud)
库/的build.gradle
dependencies {
implementation 'com.google.code.gson:gson:2.8.2' <- gson is just example, it can be anything.
}
Run Code Online (Sandbox Code Playgroud)
在上面的情况下我可以使用MainActivity.class中的Gson吗?它似乎不起作用..
如果没有,有没有办法实现这一目标?
我不想为应用程序和库添加相同的依赖项.如果Gson更新,我必须修改两个位置,我讨厌它!:(
是否可以通过Android应用程序以编程方式检测手机支持的Java版本?
即查看手机是否可以运行java 8字节码?
为什么当我尝试将 firebase-admin 添加到我的 android 项目时,gradle 告诉我“版本 5.5.0 低于 google-services 插件所需的最低版本(9.0.0)”但是 firebase 的版本 5.5.0-管理员目前是最新的。什么?
构建.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.bumptech.glide:glide:4.3.1'
compile 'com.github.GrenderG:Toasty:1.2.5'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
compile group: 'com.google.firebase', name: 'firebase-admin', version: '5.5.0'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.android.gms:play-services-auth:11.6.2'
implementation 'com.google.firebase:firebase-storage:11.6.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud) 我正在尝试一次添加两个快捷方式。但是 android 8 显示一个对话框并请求用户允许添加快捷方式,并且其中两个对话框无法同时显示。
因此,我需要一种方法,可以在第一个对话框关闭时获得回调或广播,以便之后添加另一个快捷方式。目前,当用户允许请求时,我能够获得广播。但我想知道用户是否取消了对话框。
我正在使用以下代码:
@RequiresApi(api = Build.VERSION_CODES.O)
private static void addShortcutNew(Context context, Intent shortcutIntent, String label, int iconRes, int color) {
ShortcutManager manager = context.getSystemService(ShortcutManager.class);
if (manager != null && manager.isRequestPinShortcutSupported()) {
ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(context, label)
.setIcon(prepareIcon(context, iconRes, color)) // prepareIcon is my own method which returns an Icon.
.setIntent(shortcutIntent)
.setShortLabel(label)
.setLongLabel(label)
.build();
context.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Broadcast", Toast.LENGTH_SHORT).show();
context.unregisterReceiver(this);
}
}, new IntentFilter("test_action"));
Intent …Run Code Online (Sandbox Code Playgroud) java android android-broadcast android-shortcut android-shortcutmanager
我是 Android 新手,我正在做一些关于使用各种视图的练习。一个这样的例子是:
TextView messageView = (TextView) findViewById(R.id.message);
Run Code Online (Sandbox Code Playgroud)
我的问题是:投射 TextView 有什么好处?我的 IDE 告诉我强制转换方法是多余的。是否有任何用例我想以这种方式进行投射?
我有一个textView如下:
<TextView
android:id="@+id/pointsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pointTextView"
android:ellipsize="start"
android:lines="2"
android:paddingEnd="5dp"
android:paddingStart="5dp"
android:text="this is a very very very very very very very very very very very very very very very very very very very very very long sentence." />
Run Code Online (Sandbox Code Playgroud)
这里ellipsize="end"工作得很完美,但是ellipsize="start"当没有线条不是1时,它不会变形.
如何在具有2个或更多行的TextView中使这个工作?
每当我显示时Toast,应用程序崩溃.
如果我使用旧版本的AppCompat库或fontFamily从样式中删除,该应用程序工作正常.
的onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this, "Test", Toast.LENGTH_SHORT).show(); //line 13
}
Run Code Online (Sandbox Code Playgroud)
相关性:
compile 'com.android.support:appcompat-v7:26.1.0'
Run Code Online (Sandbox Code Playgroud)
AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
引起:java.lang.ArrayIndexOutOfBoundsException:length = 16; 在android.content.res.X.B.Adray.loadStringValueAt的android.content.res.XmlBlock $ Parser.getPooledString(XmlBlock.java:458)的android.content.res.StringBlock.get(StringBlock.java:65)索引= 233 TypedArray.java:1212)在Android.support.v7.widget.TintTypedArray.getString(TintTypedArray.java:143)android.content.res.TypedArray.getString(TypedArray.java:202)的android.support.v7.:347)位于android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:152)的.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:215)位于android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81),位于android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater)的android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71). java:103)在android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024))android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)的android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)上的android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)在android.view.LayoutInflater.rInflate(LayoutInflater.java:858)的android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)在android.view上的android.view.LayoutInflater.inflate(LayoutInflater.java:518). LayoutInflater.inflate(LayoutInflater.java:426)位于android.view.LayoutInflater.inflate(LayoutInflater.java:377)的android.widget.Toast.makeText(Toast.java:266)at io.yarsa.blankapp.MainActivity.onCreate (MainActivity.java:13)在android.app.Anstrumentation.callActivityOnCreate(Instrumentation.java:1119)android.app.ActivityThread.performLaunchActivity(ActivityThread.java)的android.app.Activity.performCreate(Activity.java:6679). 2618)在Android.app.A的android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)android.app.Loper.loop上的android.app.A.运行时,Android.O.运行时,运行android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1477)的ctivityThread.-wrap12(ActivityThread.java)(Handler.java:102) Looper.java:154)在android.app.ActivityThread.main(ActivityThread.java:6126)的java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run( ZygoteInit.java:886)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
有没有其他选择,以便我可以使用fontFamily最新版本的AppCompat库在主题中使用该属性?
我在创建的 StackPane 布局中添加了两个图像视图,但是当我尝试在 StackPane 布局中添加按钮节点时,虽然图像工作得很好,但按钮不允许程序运行并抛出此错误我无法弄清楚的例外:
> > Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException: Invalid identifier.
/C:/Users/Steli/Dropbox/Java_Projects/IntelliJ%20IDEA%20Projects/DokkanCardsPreview/out/production/DokkanCardsPreview/fxml/home.fxml:33
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
at javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:901)
at javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:971)
at javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:220)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:744)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试将多个图像上传到服务器并通过 Asynctask 将它们一张一张地发送。上传图像后,我将 URL 保存到本地列表并将其发送到 onPostExecute 中进行处理。但是,我遇到了问题,因为 onPostExecute 触发得太早并且 doInBackground 只返回空列表。
将 URI 传递给 Asynctask
new UploadImages().execute(arrayUri);
Run Code Online (Sandbox Code Playgroud)
我的异步任务
private class UploadImages extends AsyncTask<Uri,Void,List<String>>{
@Override
protected List<String> doInBackground(Uri... params) {
final ArrayList<String> urlList = new ArrayList<>();
for(Uri uri : params) {
File file = new File(uri.getPath());
RequestBody requestBody = RequestBody.create(MediaType.parse("image/*"), file);
MultipartBody.Part body = MultipartBody.Part.createFormData("image", file.getName(), requestBody);
RequestBody folderName = RequestBody.create(MediaType.parse("text/plain"), folder);
ApiEndpointInterface apiEndpointInterface = RetrofitManager.getApiInterface();
Call<FileInfo> call4File = apiEndpointInterface.postFile(body, folderName);
call4File.enqueue(new ApiCallback<FileInfo>() {
@Override
protected void do4Failure(Throwable t) {
Log.d(TAG, …Run Code Online (Sandbox Code Playgroud)