Adding aar library into cn1lib project - codenameone

We're currently coding a cn1lib for OpenTok framework, but we're stuck at the inclusion of the required libraries.
We need the appcompat-V7-18.0.0.aar and support-v4-18.0.0.jar in order to use the opentok-android-sdk-2.11.0.aar, but we failed at including them.
We get this log from the CN1 build server and use this codenameone_library_appended.properties :
codename1.arg.android.proguardKeep=-keep class android.support.v4.** { *; } -keep class android.support.v7.** { *; } -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.app.Activity -keep public class * extends android.preference.Preference -keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.READ_LOGS" /> <uses-permission android\:name\="android.permission.ACCESS_NETWORK_STATE" />
We think that something is missing in this file, but what ? At this time we're just trying to do the android part, iOS later.
Any idea will be helpful, thanks in advance :)

While there are instructions on adding AAR files in the developer guide this isn't the answer you need... Support libraries are a special case. You probably don't need these build hints either.
Check out these build hints for the Intercom cn1lib:
codename1.arg.java.version=8
codename1.arg.ios.pods=Intercom
codename1.arg.ios.pods.platform=8.0
codename1.arg.android.buildToolsVersion=25.0.1
codename1.arg.android.playServicesVersion=9.8.0
codename1.arg.android.supportv4Dep=compile 'com.android.support\:support-v4\:25.+'
You can define a different version of play services and build tools, I'm guessing 25 will be new enough to support the requirements of this library.

Related

How to not obfuscate class names but get the right simplename anyway?

I have over 20 Fragments which extends from MyFragment e.g.:
LoginFragment extends MyFragment
UploadFragment extends MyFragment
CameraFragment extends MyFragment
etc..
and MyFragment in turn extends from Fragment . So in my Android app, and whenever I inflate one of them, I call in my abstrac t class a showFragment(MyFragment f) where I fire the Adjust event,
AdjustEvent event = new AdjustEvent(EVENT_LOAD_FRAGMENT);
// Add callback parameters to this parameter.
event.addCallbackParameter("LoadFragment",
f.getClass().getSimpleName());
Adjust.trackEvent(event);
so that I can measure what fragment is how often used as kay value pair. So far so good, and during debug phase it works nice.
As you can imagine now, the getClass().getSimpleName() is being obfuscated in the produtction environment. I do not want to touch all the 20 Fragments and would be totally fine if the classes get obfuscated. But I still would like to get the class' valid getSimpleName() String..
How can I get a classes valid getSimpleName() after it was obfuscated?
I used
-keepnames class * extends com.you.package.name.MyFragment
unpacked the aar and classes.jar, and checked the build forlder for seeds.txt and mapping.txt to see the obfuscation
add below to your proguard configuration file.
-keep,allowobfuscation class * extends com.you.package.name.MyFragment

How to initialize FileTree field in Gradle custom task?

I want to create an object which implements interface FileTree in Gradle.
From what I can find from documentation FileTreeAdapter class implements FileTree, but it is internal class.
How can I initialize my object filesToDelete? And how can I find which classes implements FileTree interface from the documentation?
public class DeleteDirTask extends DefaultTask {
#InputFiles #Optional
FileTree filesToDelete = files("/src/")
...
}
How can I initialize my object filesToDelete?
Use project.fileTree(). (project.files() is for FileCollections.)
And how can I find which classes implements FileTree interface from the documentation?
The implementation classes are internal, and you shouldn't have to worry about them.

Ignore method during Proguard Obfuscation

I have been trying desperately to ignore the following method during Proguard obfuscation:
package com.foo.me;
public class MyClass extends Activity implements Callback {
...
public void setButtonColor(String color, Button button){
...
}
...
}
I feel like I've been through all the answers here with no luck. Can any share the correct statement to skip over this method with Proguard?
Thanks,
Josh
You can keep ProGuard from removing or renaming the class and the method with this configuration:
-keep class com.foo.me.MyClass {
public void setButtonColor(java.lang.String, android.widget.Button);
}
See the ProGuard manual > Examples > Processing callback methods

How to avoid that proguard obfuscates the classes annotated with #OnStart

In applications based on NetBeans Platform 7.2, it is possible to
replace the ModuleInstall classes with this code:
import org.openide.modules.OnStart;
import org.openide.modules.OnStop;
#OnStart
public final class Installer implements Runnable {
#Override
public void run() {
System.out.println("enable something...");
}
#OnStop
public static final class Down implements Runnable {
#Override
public void run() {
System.out.println("disable something...");
}
}
}
My problem is that, after obfuscation, the class loader does not find
the annotated classes.
In the Proguard configuration I added (as suggested here)
-keep #org.openide.modules.OnStart class *
But apparently this is not enough or it does not work.
Does anybody have a suggestion?
From I could figure out, you need to explicitly keep the annotations that you use to keep whatever specifications. So, in your case, adding
-keep enum org.openide.modules.OnStart
would allow this annotation to be used as a selector.
Proguard really ought to include a warning message if annotation selectors are not actually matching. It also doesn't really make sense to keep the annotation, especially if it's not of runtime retention.
Have you tried -keepattributes *Annotation*? It might do the trick, based on proguard usage.

Can mockito or easymock replace rmock

I'm sitting with a legacy project, and we're starting to replace some old legacycode. As Rmock don't have support for junit4, we would like to replace it. One thing i was wondering is - how could i replace the dynamictestsuite feature of rmock. This is a good feature where you create a dynamic testsuite for each run, and can do stuff like.
#Override
protected void setupSuite() {
forEach(is.clazz.assignableTo(TestCase.class).and(is.not(is.clazz.name(is.endingWith("oldTest")))).perform(addAllToSuite);
}
that would get all testclasses not ending with oldTest and create a dynamictestsuite. And so on, you get the point.
ClasspathSuite can define a suite by searching for JUnit test classes in the class path, with a filter on the test class names to include or exclude.
import org.junit.extensions.cpsuite.ClasspathSuite.*;
import org.junit.runner.RunWith;
#RunWith(ClasspathSuite.class)
#ClassnameFilters({"!.*oldTest"})
public class MySuite {}

Resources