我试图解密"~9?8?m???=?T?G"从后端服务器收到的字符串,该服务器使用OpenSSL使用AES-256-CBC加密字符串.有代码块:
public static String decryptText(String textToDecrypt) {
try {
byte[] base64TextToDecrypt = Base64.encodeBase64(textToDecrypt.getBytes("UTF-8"));
byte[] guid = "fjakdsjkld;asfj".getBytes("UTF-8");
byte[] iv = new byte[16];
System.arraycopy(guid, 0, iv, 0, guid.length);
IvParameterSpec ips = new IvParameterSpec(iv);
byte[] secret = DECRYPTION_SECRET_HASH.getBytes("UTF-8");
SecretKeySpec secretKey = new SecretKeySpec(secret, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
// decryption pass
cipher.init(Cipher.DECRYPT_MODE, secretKey, ips);
byte[] converted = cipher.doFinal(base64TextToDecrypt);
System.out.println(new String(converted));
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG, "Decipher error for " + textToDecrypt, e);
}
return "";
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我到达时
byte[] …Run Code Online (Sandbox Code Playgroud) 我有一个Android项目设置与robolectric测试,现在总共约2084个单元测试.但是我一直在考虑添加更多测试的问题java.lang.OutOfMemoryError: PermGen space.
objc[11380]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
java.lang.OutOfMemoryError: PermGen space
Exception in thread "Test worker" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-0" java.lang.OutOfMemoryError: PermGen space
:app:testDebug FAILED
Run Code Online (Sandbox Code Playgroud)
随着strack追踪,我得到以下
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:testDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java
...
Caused by: org.gradle.process.internal.ExecException: Process 'Gradle Test Executor 1' finished with non-zero …Run Code Online (Sandbox Code Playgroud) 我使用https://github.com/emilsjolander/StickyListHeaders作为我的大多数应用程序的主要列表视图.我把这个listview放在我用于所有listview的一个布局中.但是,有些情况下我不想显示任何标题,我只想显示一个常规列表,如listview.
有没有办法将StickyListHeaders设置为根本不显示标题?有一些选项可以使标题不粘.我希望标题不显示,现有的API可能吗?
@Override
public View getHeaderView(int position, View convertView, ViewGroup parent) {
// do nothing
return null;
}
@Override
public long getHeaderId(int position) {
// do nothing
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我最终将使用JAR文件运行的旧单元测试迁移到使用gradle但是我在获取正确的组合时遇到了很多麻烦,并且不确定我在做什么是对还是错.首先,这些是我正在使用的所有jar文件.
dexmaker-1.0.jar
dexmaker-mockito-1.0.jar
fest-android-1.0.7.jar
fest-assert-core-2.0M10.jar
fest-util-1.2.5.jar
junit-4.11.jar
mockito-all-1.9.5.jar
the-missing-android-xml-junit-test-runner-release-1.3_2.jar <---- I think this is used to get reports for the unit tests, is there a way that I don't have to use this anymore?
Run Code Online (Sandbox Code Playgroud)
当我将所有这些JAR导入时,就像下面的JAR一样,它运行正常,所以这是一件好事,但并不理想:
androidTestCompile fileTree(dir: 'libs/test', include: '*.jar')
Run Code Online (Sandbox Code Playgroud)
接下来,我尝试将所有JAR文件更改为gradle-maven依赖项,如下所示
androidTestCompile fileTree(dir: 'libs/test', include: '*.jar')
androidTestCompile 'junit:junit:4.11+'
androidTestCompile ('com.squareup:fest-android:1.0.+') {
exclude group: 'com.android.support'
}
androidTestCompile 'org.easytesting:fest-assert-core:2.0M10'
androidTestCompile 'org.easytesting:fest-util:1.2.+'
androidTestCompile 'org.mockito:mockito-all:1.9.+'
androidTestCompile 'com.google.dexmaker:dexmaker:1.+'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.+'
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为在尝试构建和运行单元测试时,我得到以下结果:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
... …Run Code Online (Sandbox Code Playgroud) 我有一个使用Dagger的Android应用.整个应用程序的某些部分我想为几个共享共同范围的活动添加范围的ObjectGraphs.以下模块位于根ObjectGraph中
@Module(
injects = {
MyApplication.class,
},
complete = false,
library = true)
public class BasicContextManagerModule {
private Context applicationContext;
public BasicContextManagerModule(Context applicationContext) {
this.applicationContext = applicationContext;
}
@Provides
Context getApplicationContext() {
return applicationContext;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试通过existingObjectGraph.plus(new FileManagerModule())添加以下模块;
@Module(
injects = {
MyListActivity.class,
MyFileDetailActivity.class,
MyFileInfoActivity.class,
},
includes = BasicContextManagerModule.class
)
public class FileManagerModule {
@Provides
FileManager provideFileManager(Context context) {
return new FileManager(context);
}
}
Run Code Online (Sandbox Code Playgroud)
但结果是
java.lang.UnsupportedOperationException: No no-args constructor com.myapp.core.modules.BasicContextManagerModule$$ModuleAdapter
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我理解为什么加号不会允许这个?我从匕首文档中读到,扩展了对象图,你可以使用includes和addsTo Modules.但我无法做到这一点.