Cannot resolve method 'formKey' in ACRA 4.7.0 - android

i tried setting up acra for my android project today, but it didnt work. I followed the instructions, importet the acra lib in gradle (compile 'ch.acra:acra:4.7.0')
Then i added this:
#ReportsCrashes(formKey = "", mailTo = "mail#adress.com", mode = ReportingInteractionMode.NOTIFICATION)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ACRA.init(this.getApplication());
I get the error Cannot resolve method 'formKey', but when deleting formkey from parameters, i get #ReportsCrashes not applicable to method
I also tried
#ReportsCrashes(formUri = "http://www.yourselectedbackend.com/reportpath")
and
#ReportsCrashes(formKey = "", formUri = "http://www.yourselectedbackend.com/reportpath")
and get the same errors. Anyone knows the issue/solution? The wiki at https://github.com/ACRA/acra/wiki seems outdated and there is no issue about this.

formKey has been removed for some time. I don't know where you saw instructions to use it, but they should no longer exist too. Use formUri.
You are getting #ReportsCrashes not applicable to method because you have annotated your onCreate method. You need to annotate your Application class

Related

Kotlin crashes during initialization - CollectionsKt.first

I see a crash whenever my android app initializes a kotlin class. From the stack trace, I see it's from the static initializer of the BuiltInsLoader.Companion object:
kotlin.collections.CollectionsKt___CollectionsKt.first
(CollectionsKt___CollectionsKt.java:166)
kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader$Companion.
(BuiltInsLoader.java:38)
kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader.
(BuiltInsLoader.java)
kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns.createBuiltInsModule
(KotlinBuiltIns.java:150)
kotlin.reflect.jvm.internal.impl.platform.JvmBuiltIns.
(JvmBuiltIns.java:56)
kotlin.reflect.jvm.internal.impl.platform.JvmBuiltIns.
(JvmBuiltIns.java:31)
kotlin.reflect.jvm.internal.components.RuntimeModuleData$Companion.create
(RuntimeModuleData.java:54)
kotlin.reflect.jvm.internal.KDeclarationContainerImpl$Data$moduleData$2.invoke
(KDeclarationContainerImpl.java:35)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.getModuleData
(ReflectProperties.java:32)
kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.invoke
(KClassImpl.java:46)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.getDescriptor
(ReflectProperties.java:32)
kotlin.reflect.jvm.internal.KClassImpl.getDescriptor
(KClassImpl.java:172)
kotlin.reflect.jvm.internal.KClassImpl.getConstructorDescriptors
(KClassImpl.java:186)
kotlin.reflect.jvm.internal.KClassImpl$Data$constructors$2.invoke
(KClassImpl.java:90)
kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke
(ReflectProperties.java:93)
kotlin.reflect.jvm.internal.ReflectProperties$Val.create
(ReflectProperties.java:32)
The decompiled static block looks like this:
BuiltInsLoader.Companion var0 = new BuiltInsLoader.Companion();
$$INSTANCE = var0;
ServiceLoader var10000 = ServiceLoader.load(BuiltInsLoader.class, BuiltInsLoader.class.getClassLoader());
Intrinsics.checkExpressionValueIsNotNull(var10000, "ServiceLoader.load(Built…::class.java.classLoader)");
Object var1 = CollectionsKt.first((Iterable)var10000);
Has anyone else experienced this crash? If so, how do you fix this initialization error?
This exception can occur if a certain resource file, needed for kotlin-reflect to work correctly, is missing at runtime. The file is located at META-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader. Please verify that no tools remove it during the build and it's present in the final application.
The relevant issue in the Kotlin tracker: https://youtrack.jetbrains.com/issue/KT-20575
Maybe:
packagingOptions {
exclude 'META-INF/services/kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader'
}
Might help

Titanium Hyperloop access to android.os.SystemProperties

I have been trying a ( i hope) simple bit of Android hyperloop code directly within a titanium project (using SDK 7.0.1.GA and hyperloop 3).
var sysProp = require('android.os.SystemProperties');
var serialNumber = sysProp.get("sys.serialnumber", "none");
But when the app is run it reports
Requested module not found:android.os.SystemProperties
I think this maybe due to the fact that when compiling the app (using the cli) it reports
hyperloop:generateSources: Skipping Hyperloop wrapper generation, no usage found ...
I have similar code in a jar and if I use this then it does work, so I am wondering why the hyperloop generation is not being triggered, as I assume that is the issue.
Sorry should have explained better.
This is the jar source that I use, the extraction of the serial number was just an example (I need access to other info manufacturer specific data as well), I wanted to see if I could replicate the JAR functionality using just hyperloop rather that including the JAR file. Guess if it's not broke don't fix it, but was curious to see if it could be done.
So with the feedback from #miga and a bit of trial and error, I have come up with a solution that works really well and will do the method reflection that is required. My new Hyperloop function is
function getData(data){
var result = false;
var Class = require("java.lang.Class");
var String = require("java.lang.String");
var c = Class.forName("android.os.SystemProperties");
var get = c.getMethod("get", String.class, String.class);
result = get.invoke(c, data, "Error");
return result;
}
Where data is a string of the system property I want.
I am using it to extract and match a serial number from a Samsung device that is a System Property call "ril.serialnumber" or "sys.serialnumber". Now I can use the above function to do what I was using the JAR file for. Just thought I'd share in case anyone else needed something similar.
It is because android.os.SystemProperties is not class you can import. Check the android documentation at https://developer.android.com/reference/android/os/package-summary.html
You could use
var build = require('android.os.Build');
console.log(build.SERIAL);
to access the serial number.

Unity Plugin AndroidJavaException NoSuchMethodError on Function with parameters

I got a very annoying issue. All of my Android plugins in Unity just work if I dont use parameters in the calling functions. I am working on this issue since 2 days and I am slowly running out of ideas. Even a minimal project doesnt work. I am sure Iam doing it right because my functions are working fine without parameters.
Unity:
void Start (){
AndroidJavaClass pluginClass = new AndroidJavaClass("tnbrtrm.lications.de.myplugin.MyPlugin");
String test = pluginClass.CallStatic<string>("getMessage", new object[] { "alalalalala" });
Debug.Log("callShareAppAARPlugin: " + test);}
Android:
public class MyPlugin extends UnityPlayerActivity {
public static String getMessage(String text)
{ return "Hello World! " + text; }
}
My plugin prints "Hello world" correctly when I delete the parameter "String text", but with parameter I get this annoying error:
AndroidJavaException: java.lang.NoSuchMethodError: no static method "Ltnbrtrm/lications/de/myplugin/MyPlugin;.getMessage(Ljava/lang/String;)Ljava/lang/String;"
I see this error using Plugins as *.jar or *.aar. And I also had a look into this packages and my Classes and Functions are there. Otherwise it wouldnt work without parameters... I tried AndroidJavaClass and AndroidJavaObject.
Can anyone please help me? I tried a lot of things... (older JDK versions, etc.) I seems so easy in all the turorials so I assume it has something to do with my system or unity (5.3.5 pro).
Kind regards,
Tino

Android ACRA - Application Crash Reporting for Android

I am trying to figure out how to add ACRA in my test project in Android Studio.
Following this article (which explains how to do it in Eclipse) https://github.com/ACRA/acra/wiki/BasicSetup, I have passed all so far up to the point where is explains to annotate your Application class with #ReportsCrashes. In this part, I dont know what to put as formUri.
I am just creating my own test app (API22 Lollipop) and trying to add ACRA support to it. I don't have any server, it is just a simple Android app.
import org.acra.*;
import org.acra.annotation.*;
#ReportsCrashes(
formKey = "", // This is required for backward compatibility but not used
formUri = "http://www.backendofyourchoice.com/reportpath"
)
public class MyApplication extends Application {
}
What do I put as the formUri?
Can you explain what formUri is for and how it works as I am new to dev?
Please explain
Thanks,
formUri points to your crash report server.
There are many to choose from, commercial and free.
The ACRA wiki lists several.
ACRAlyzer is one, but you will need to host it yourself.
Read about Acralyzer: https://github.com/ACRA/acralyzer/wiki/setup
It is simple backend for ACRA reports.
#ReportsCrashes(
formUri = "https://[your.couchdb.host]/acra-[yourappname]/_design/acra-storage/_update/report",
formUriBasicAuthLogin="[reporteruser]",
formUriBasicAuthPassword="[reporterpassword]",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
....
)
public class [YourApplication] extends Application {
#Override
public final void onCreate() {
super.onCreate();
ACRA.init(this);
}
There you will find the usage of the Acralyzer user interface: https://github.com/ACRA/acralyzer/wiki/usermanual

New relic plugin on Eclipse Android

So I'm on a Mac with Eclipse and I'm trying to add the new relic plugin. I've already followed the instructions up to import.
import com.newrelic.agent.android.NewRelic;
But now when I try to add the code:
NewRelic.withApplicationToken(mycode).start(this.getApplication());
where mycode is just the id as String given to me by new relic. I get an error that says:
Syntax error on token "withApplicationToken", = expected after this token
Any ideas?
I think there might be some error in where this line was added or how the token was formatted.
Here's the exact formatting for this code, in its context:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NewRelic.withApplicationToken(
"AA9b032a80e2658208a0180ec09ff1f059badb7756"
).start(this.getApplication());
setContentView(R.layout.lookup);
That's just a demo token, I've altered some characters in my token so that you won't start sending to my dashboard :)
If that doesn't fix it, I would send a complete code snippet to New Relic in a support ticket, either under 'help' in your dashboard or at support#newrelic.com.
If you do open a ticket and there's a general solution, I'll come back here and post the right steps for other users.
This line looks fine. Is there a missing semicolon or something in the previous line? Can you verify that?

Categories

Resources