小编ift*_*hem的帖子

当我运行单元测试时,android 上的 Logback 2.0 给出 NullPointerException

我转向了 logback 2.0。当我运行单元测试(使用@Test)时,所有测试都运行良好。然而他们给出了一个错误:

Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
java.lang.NullPointerException
at ch.qos.logback.core.android.AndroidContextUtil.getMountedExternalStorageDirectoryPath(Unknown Source)
at ch.qos.logback.core.android.AndroidContextUtil.setupProperties(Unknown Source)
at org.slf4j.impl.StaticLoggerBinder.init(Unknown Source)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(Unknown Source)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at com.accells.MyApplication.<clinit>(MyApplication.java:35)
at sun.reflect.GeneratedSerializationConstructorAccessor7.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)
...
Run Code Online (Sandbox Code Playgroud)

MyApplication 类扩展了 Application 类。它包含以下行:

private static final Logger logger = LoggerFactory.getLogger(MyApplication.class);
Run Code Online (Sandbox Code Playgroud)

我正在使用代码来设置 logback 配置。登录配置是:

public static void configure(Context context, String logFileName) {
    String appInfo = String.format(APP_INFO_PATTERN, AppUtils.getVersionName(context), CommunicationManager.API_VERSION, AppUtils.getAndroidVersion(), Build.MODEL);
    String logPattern = LOG_PATTERN.replace("__app__info__", appInfo).replace("%pid", String.valueOf(android.os.Process.myPid()));
    // since …
Run Code Online (Sandbox Code Playgroud)

testng android unit-testing logback nullpointerexception

6
推荐指数
0
解决办法
760
查看次数

初始化 android 的 flurry 时出错

I\xe2\x80\x99m 使用 FlurryAnalytics-5.5.0.jar。当我初始化 Flurry 时,我收到一些错误:

\n\n
FlurryAgent.setLogEnabled(true);\nFlurryAgent.setLogEvents(true);\nFlurryAgent.setLogLevel(android.util.Log.ERROR);\nFlurryAgent.init(this, FLURRY_ID);\n
Run Code Online (Sandbox Code Playgroud)\n\n

错误:

\n\n
\n

找不到类“com.flurry.sdk.br”,从方法引用\n com.flurry.sdk.bq.a

\n
\n\n

\n\n
\n

Google Play 服务库存在问题,\n 这是 Android 广告 ID 支持所必需的。Google Play 服务库应集成到 Play 商店中使用分析或广告的任何应用程序中。

\n
\n\n

你能给些建议么?

\n

android runtime-error flurry

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

如何中断BlockingQueue?

BlockingQueue.put可以抛出InterruptedException.如何通过抛出此异常导致队列中断?

ArrayBlockingQueue<Param> queue = new ArrayBlockingQueue<Param>(NUMBER_OF_MEMBERS);
...
try {
    queue.put(param);
} catch (InterruptedException e) {
    Log.w(TAG, "put Interrupted", e);
}
...
// how can I queue.notify?
Run Code Online (Sandbox Code Playgroud)

java concurrency android interrupt blocking

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