小编Xi *_*Wei的帖子

libs文件夹在android studio中不起作用

我使用的是android studio 1.2 Beta 2的mac版本,建于2015年4月7日.Gradle版本2.2.1和Gradle插件版本1.1.0.

创建新项目后,默认情况下,我的app/build.gradle文件中存在以下代码.

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)

这意味着我添加到app/libs目录的任何jar文件都应该加载到我的项目中,对吗?但是,当我将Parse-1.9.0.jar添加到app/libs时,它没有被加载.我没能在MainActivity.java中使用API​​中的代码.

右键单击Parse-1.9.0.jar - > Add As Library ... app/build.gradle成为:

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/Parse-1.9.0.jar')
}
Run Code Online (Sandbox Code Playgroud)

我很困惑为什么.不应该编译fileTree()包含所有jar文件?为什么我需要做额外的步骤?

我下载的Parse-1.9.0.jar文件来自:https://parse.com/apps/quickstart#parse_data/mobile/android/native/existing

谢谢

android gradle parse-platform android-studio android-gradle-plugin

13
推荐指数
3
解决办法
3685
查看次数

以编程方式更改 ConstraintLayout 中的宽度和高度不起作用

我想以编程方式将以下 UI 更改为全屏。

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    >

    <TextView
        android:id="@+id/one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="ONE"
        android:background="@android:color/darker_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/two"

        />

    <TextView
        android:id="@+id/two"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TWO"
        android:background="@android:color/holo_blue_dark"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toRightOf="@+id/one"
        />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

在我的 Kotlin 文件中:

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val param = ConstraintLayout.LayoutParams(0, 0)

        one.layoutParams = param
        two.layoutParams = param
    }
}
Run Code Online (Sandbox Code Playgroud)

在我将宽度和高度设置为 0 而不是全屏刮擦后,两个 TextView 都消失了。

所需的用户界面 在此处输入图片说明

android android-layout android-constraintlayout

8
推荐指数
1
解决办法
6647
查看次数

android中没有System.lineSeparator()

System.lineSeparator()我正在进行Android开发时无法使用.我不得不使用旧版本System.getProperty("line.separator").

任何人都可以向我解释为什么会这样?是因为Android SDK没有使用Java 7吗?

java android

7
推荐指数
1
解决办法
7035
查看次数

我在Android Studio中使用哪个版本的JDK无关紧要?

我知道我可以在Android Studio的项目结构中选择SDK位置。 项目结构,SDK位置

我有两个问题:

  1. 当我们已经在使用Android SDK时,为什么需要JDK?毕竟,我们不是在为JVM开发。

  2. 使用JDK 1.6、1.7和1.8有什么区别吗?

java android android-studio

5
推荐指数
1
解决办法
4069
查看次数

圆角半径的范围是多少?

我知道如何使用圆角对于视图将是这样的:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="10dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

半径范围是多少?它是0到100 dp?

android android-layout

5
推荐指数
1
解决办法
1495
查看次数

如何使用crashlytics报告第三方NDK崩溃

我从Google Play控制台收到以下NDK崩溃报告,但在Crashlytics中没有.

#00  pc 0000000000049c44  /system/lib/libc.so (tgkill+12)
#01  pc 00000000000473e3  /system/lib/libc.so (pthread_kill+34)
#02  pc 000000000001d535  /system/lib/libc.so (raise+10)
#03  pc 0000000000019081  /system/lib/libc.so (__libc_android_abort+34)
#04  pc 00000000000170e4  /system/lib/libc.so (abort+4)
#05  pc 000000000000c3a1  /system/lib/libcutils.so (__android_log_assert+112)
#06  pc 000000000002352d  /system/lib/libhwui.so
#07  pc 0000000000024db3  /system/lib/libhwui.so
#08  pc 00000000000281a9  /system/lib/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+80)
#09  pc 000000000000e361  /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+140)
#10  pc 0000000000064d19  /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+80)
#11  pc 0000000000046eb3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
#12  pc 0000000000019acd  /system/lib/libc.so (__start_thread+6)
Run Code Online (Sandbox Code Playgroud)

我想让Crashltytics也报告这些崩溃事件.我们不使用任何NDK库,崩溃应来自外部第三方库.我正在阅读https://docs.fabric.io/android/crashlytics/ndk.html,但仍不确定如何做到这一点.

问题1

鉴于我已经在我的Android应用程序中使用Crashlytics,我必须做出/添加的确切配置更改,以便崩溃报告NDK从外部第三方库崩溃?

问题2

https://docs.fabric.io/android/crashlytics/ndk.html中,它提到了Uploading symbols for external dependencies.什么是 …

android android-ndk crashlytics

4
推荐指数
1
解决办法
1088
查看次数

如何确保用户只能在firebase中查看和访问自己的数据?

我是firebase的新手.在我的Android应用中,我希望每个用户只能访问他创建的数据.我正在阅读https://www.firebase.com/docs/security/guide/securing-data.html,但没有太多意义.假设我已经使用电子邮件和密码登录,

  1. 我该如何编写Firebase规则?
  2. 如何在我的Android Java代码中写入我的Firebase数据?

谢谢!

Firebase规则

{
    "rules": {
        ".read": true,
        ".write": true
    }
}
Run Code Online (Sandbox Code Playgroud)

Java代码

myFirebaseRef.child("message").setValue("This is the message");
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-security firebase-authentication

2
推荐指数
1
解决办法
4860
查看次数

如何在Java中引用Kotlin对象类型?

我有如下的Kotlin对象:

object TestObject {
    val name: String = "Hi"
}
Run Code Online (Sandbox Code Playgroud)

我将如何TestObject用Java 引用?以下代码无法理解TestObject.name

public class Main {
    public static void main(String[] args) {
        System.out.println(TestObject.name);
    }
}
Run Code Online (Sandbox Code Playgroud)

java kotlin

0
推荐指数
1
解决办法
61
查看次数