小编Len*_*Bru的帖子

使用RestKit获取我的对象的JSON字符串

我想创建一个json字符串以保存NSUserDefaults,然后从中获取它.

我已经将RestKit添加到我的项目中,以便从服务器发送和接收对象.但是,现在我想要展平并保存数据.

如何使用restkit获取对象的JSON字符串?

json ios restkit restkit-0.20

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

以维度分配包装内容

我想支持小屏幕和大屏幕

我的布局中有一个图像视图 - 在小屏幕中,它需要布局高度为"wrap_content"

在大屏幕上它需要400dp(包装内容太小)

而不是创建另一个布局,我想创建一个维度

<dimen name="layout_height">wrap_content</dimen>

<dimen name="layout_height">400dp</dimen>
Run Code Online (Sandbox Code Playgroud)

并将它们分配到正确的文件夹和我的imageview写入

layout_height=@dimen/layout_height
Run Code Online (Sandbox Code Playgroud)

这有可能以任何方式,而不创建另一个布局?

android dimensions android-layout

5
推荐指数
2
解决办法
3532
查看次数

How to configure %APP_NAME% in firebase app?

I configured the phone authentication service However when i receive the SMS it displays something atrocious.

I get something like "firebase-production.app..."

How to fix it ?

firebase firebase-authentication

5
推荐指数
3
解决办法
2254
查看次数

Proguard 删除 lambda 调用

我有一个如下所示的方法

HashMap.doSomething(block:(SpecificTypeOfObject)->Unit){
  forEach{ (k,v) ->
      (v as? SpecificTypeOfObject)?.let {
          block(it)
       }

   }
}
Run Code Online (Sandbox Code Playgroud)

当我启用 proguard 时,该块被擦除 如何让 proguard 保留它?

java.lang.NoSuchMethodError: No interface method invoke(Ljava/lang/Object;)Ljava/lang/Object; in class Lkt6; or its super classes (declaration of 'kt6' appears in /data/app/com.app.client-_zT-qCWwu71b-k9s0YyjOQ==/base.apk!classes3.dex)
Run Code Online (Sandbox Code Playgroud)

proguard kotlin

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

如何为 Android 启用 AllOpen 插件

我正在尝试为 android 添加allopen插件。

我把这个添加到我的build.gradle(.)

ext.kotlin_version = '1.3.61'

classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
Run Code Online (Sandbox Code Playgroud)

我把这个添加到我的app/build.gradle

apply plugin: 'kotlin-allopen'
apply plugin: 'io.fabric'

allOpen {
    annotation('com.myapp.sidemodule.Mockable')
}
Run Code Online (Sandbox Code Playgroud)

由于项目结构的原因,注释与属于 App 的模块位于不同的模块中

我在 sidemodule/debug/Mockable 中添加了这个

@Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class Mockable
Run Code Online (Sandbox Code Playgroud)

然后在 sidemodule/debug/OpenClass 中

@Mockable
@Target(AnnotationTarget.CLASS)
annotation class OpenClass
Run Code Online (Sandbox Code Playgroud)

然后在 sidemodule/release/OpenClass 中

@Target(AnnotationTarget.CLASS)
annotation class OpenClass
Run Code Online (Sandbox Code Playgroud)

我添加 @OpenClass到了我注定要被嘲笑的班级但是,我仍然收到:

E/TestRunner: failed: testCanDetectBadResponse(com.myapp.test.core.SomeTests)
    ----- begin exception -----
    org.mockito.exceptions.base.MockitoException: 
    Cannot mock/spy class com.myapp.models.MyResponse
    Mockito cannot mock/spy because :
     - final class
        at com.nhaarman.mockitokotlin2.SpyingKt.spy(Spying.kt:52)
        at com.myapp.test.core.SomeTests.testCanDetectBadResponse(SomeTests.kt:163)
        at java.lang.reflect.Method.invoke(Native Method)
        at …
Run Code Online (Sandbox Code Playgroud)

android kotlin-allopen

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

ActivityScenario.launch 寻找一些缓存的 jar

我正在运行 android 仪器测试,我有以下代码:

    lateinit var scenario: ActivityScenario<MainActivity>

@Before
fun before(){
    scenario = ActivityScenario.launch(MainActivity::class.java)
}
Run Code Online (Sandbox Code Playgroud)

测试本身运行良好。

但是,每次启动套件(或单个测试)时,我都会在日志中看到以下内容

E/System: Unable to open zip file: /data/user/0/com.my.app/cache/dFBYiv5m.jar
E/System: java.io.FileNotFoundException: /data/user/0/com.my.app/cache/dFBYiv5m.jar (No such file or directory)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:265)
        at java.util.zip.ZipFile.<init>(ZipFile.java:187)
        at java.util.jar.JarFile.<init>(JarFile.java:169)
        at java.util.jar.JarFile.<init>(JarFile.java:106)
        at libcore.io.ClassPathURLStreamHandler.<init>(ClassPathURLStreamHandler.java:46)
        at dalvik.system.DexPathList$Element.maybeInit(DexPathList.java:756)
        at dalvik.system.DexPathList$Element.findResource(DexPathList.java:783)
        at dalvik.system.DexPathList.findResources(DexPathList.java:578)
        at dalvik.system.BaseDexClassLoader.findResources(BaseDexClassLoader.java:248)
        at java.lang.ClassLoader.getResources(ClassLoader.java:839)
        at java.util.ServiceLoader$LazyIterator.hasNextService(ServiceLoader.java:349)
        at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:402)
        at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:488)
        at androidx.test.internal.platform.ServiceLoaderWrapper.loadService(ServiceLoaderWrapper.java:46)
        at androidx.test.internal.platform.ServiceLoaderWrapper.loadSingleService(ServiceLoaderWrapper.java:69)
        at androidx.test.core.app.ActivityScenario.<init>(ActivityScenario.java:140)
        at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:189)
        at com.my.app.test.authFlow.OnboardingFlowSteps.before(OnboardingFlowSteps.kt:80)
        at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) …
Run Code Online (Sandbox Code Playgroud)

android android-instrumentation activity-scenario

5
推荐指数
0
解决办法
144
查看次数

如何将 Android 应用程序限制为 64 位平台在 google play 上下载

我有一个仅在 64 位配置下运行的应用程序。我已将以下内容放入 abi 过滤器中

splits{
    abi {
        enable true
        reset()
        include "x86_64", "arm64-v8a"
        universalApk true
    }
}
Run Code Online (Sandbox Code Playgroud)

但是当我上传 alpha track 应用程序时,我看到了这个:

在此输入图像描述

如何确保我的应用程序不可用于 64 位设备以外的其他设备下载?

64-bit android android-app-bundle

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

inflaters有什么区别

这样做有什么区别

LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Run Code Online (Sandbox Code Playgroud)

inflater = LayoutInflater.from(activity);

android layout-inflater

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

找不到类型^的证据参数的隐含值

我正在尝试为Post请求编写测试

这是我的代码:

val request = CreateLinkRequest(token = Some(validToken),billing_ref_id = Some("123"), store_id = Some("123"), agent_id = Some("123"))

val endPoint = Uri(this.serverRootUrl + "path").toString
val post = Post(endPoint, request)
val pipeline = jsonAsStringPipeline(post)
val responseContents = Await.ready(pipeline, atMost = callMaxWaitDuration)
Run Code Online (Sandbox Code Playgroud)

但这不编译,我不断收到此错误:

Error:(156, 20) could not find implicit value for evidence parameter of type spray.httpx.marshalling.Marshaller[CreateLinkSpec.this.CreateLinkRequest]
    val post = Post(endPoint, request)
               ^
Error:(156, 20) not enough arguments for method apply: (implicit evidence$1: 

spray.httpx.marshalling.Marshaller[CreateLinkSpec.this.CreateLinkRequest])spray.http.HttpRequest in class RequestBuilder.
Unspecified value parameter evidence$1.
    val post = Post(endPoint, …
Run Code Online (Sandbox Code Playgroud)

scala spray-json

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

转发声明一种类型 - 这背后的原因是什么

/* Forward declare a type "point" to be a struct. */
typedef struct point point;
/* Declare the struct with integer members x, y */
struct point {
   int    x;
   int    y;
};
Run Code Online (Sandbox Code Playgroud)

你能解释一下前方宣布的原因吗?

c

3
推荐指数
1
解决办法
256
查看次数