My Android app has Crashlytics all set up and I made a small code to generate a native crash to test the reports. I've followed every setup instruction and I am using the latest Crashlytics version.
When I execute my crash test in debug mode, reports arrive with readable and precise stack traces. However, when I do the same test on the release build of my app, I do get crash reports with readable stack traces but they point to wrong locations in my code.
Coincidentally or not, the misleading traces point to another method that lies right below the actual origin of the crash. I do get file name and lines though, only there's no way the crash could be coming from the source it points to.
The native source is built using regular CMakeLists.txt and is being loaded from another library module that accommodates my native library.
Both debug and release symbols are being uploaded with the following commands:
./gradlew app-module:assemblerelease app-module:uploadCrashlyticsSymbolFilerelease
./gradlew app-module:assembledebug app-module:uploadCrashlyticsSymbolFiledebug
Has anyone ever experienced it before? What could be causing these readable but slightly misleading traces only in release mode?
EDIT:
The reason why I believe the trace misplacement is sort of random and non related to inlining or unrolling is because both the actual crash source and the misplaced origin are pretty straight-forward and unrelated. Also there are no calls to ShowMessage near the part of the code where TestCrash gets called.
void ScriptWrapper::TestCrash()
{
MyObject* obj = nullptr;
obj->GetID(); // this is where the crash takes place
}
void ScriptWrapper::ShowMessage(std::string sMsg, const MESSAGE_TYPE type, const bool abort)
{
std::stringstream ss;
Logger::TYPE logType;
switch (type)
{
case ERROR:
ss << ("ERROR - ");
logType = Logger::ERROR; // this is where the release crash stack trace points at
if (abort)
{
Abort();
}
break;
case WARNING:
ss << ("Warning - ");
logType = Logger::WARNING;
break;
default:
logType = Logger::INFO;
};
ss << sMsg;
Log(ss.str(), logType);
}
Related
So I have been using the YouTube API successfully for the past few months in Android Studio. I went to update my app and as of today the app keeps crashing when it is trying to initialize the YouTube builder. Has anyone else experienced this problem?
mYoutubeDataApi = new YouTube.Builder(mTransport, mJsonFactory, null)
.setApplicationName(getResources().getString(R.string.app_name))
.build();
The app crashes with the following output:
2019-12-09 01:38:06.443 17937-17937/ E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.google.api.services.youtube.YouTube.<clinit>(YouTube.java:44)
at com.google.api.services.youtube.YouTube$Builder.build(YouTube.java:16644)
Line 44 in the YouTube.java file is:
public class YouTube extends com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient {
// Note: Leave this static initializer at the top of the file.
static {
com.google.api.client.util.Preconditions.checkState(
com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 &&
com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15,
"You are currently running with version %s of google-api-client. " +
"You need at least version 1.15 of google-api-client to run version " +
"1.30.1 of the YouTube Data API library.", com.google.api.client.googleapis.GoogleUtils.VERSION);
}
In 1.30.6, they added this: https://github.com/googleapis/google-api-java-client/pull/1419
To fix, edit your build.gradle back down to 1.30.5
dependencies {
implementation ('com.google.api-client:google-api-client:1.30.5')
implementation ('com.google.api-client:google-api-client-android:1.30.5')
}
If there's a better solution, I'd like to hear it!
To further explain why that change in 1.30.6 causes the crash, here's some more info.
Specifically, the issue is coming from this file: https://github.com/googleapis/google-api-java-client/blob/master/google-api-client/src/main/java/com/google/api/client/googleapis/GoogleUtils.java
Caused by: java.lang.IllegalStateException: No successful match so far
at java.util.regex.Matcher.ensureMatch(Matcher.java:1116)
at java.util.regex.Matcher.group(Matcher.java:382)
at com.google.api.client.googleapis.GoogleUtils.<clinit>(Unknown Source:26)
Here is the relevant code
public static final String VERSION = getVersion();
static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(-SNAPSHOT)?");
static {
Matcher versionMatcher = VERSION_PATTERN.matcher(VERSION);
versionMatcher.find();
MAJOR_VERSION = Integer.parseInt(versionMatcher.group(1));
MINOR_VERSION = Integer.parseInt(versionMatcher.group(2));
BUGFIX_VERSION = Integer.parseInt(versionMatcher.group(3));
}
private static String getVersion() {
String version = GoogleUtils.class.getPackage().getImplementationVersion();
// in a non-packaged environment (local), there's no implementation version to read
if (version == null) {
// fall back to reading from a properties file - note this value is expected to be cached
try (InputStream inputStream =
GoogleUtils.class.getResourceAsStream("google-api-client.properties")) {
if (inputStream != null) {
Properties properties = new Properties();
properties.load(inputStream);
version = properties.getProperty("google-api-client.version");
}
} catch (IOException e) {
// ignore
}
}
return version;
}
Presumably, getVersion is returning null, although I can't say why. Seeing as how this recently happened for me 2-3 days ago also, something we updated must be conflicting.
This bug is fixed in com.google.api-client:google-api-client:1.30.7. Upgrading to that version or later will fix it.
In the latest version, they have added the library proguard file, which keeps the the GoogleUtils.java and hence keeps the google-api-client.properties which gets generated in build time.
Initially they used to update the string literal for version name for each release hence that time parsing of version name done in GoogleUtils.java was crash free.
But later on they shifted to parsing the version from google-api-client.properties at GoogleUtils.java which started giving error as proguard started removing the generated google-api-client.properties file.
Later on after release, 1.30.9 at this commit id the started using the embedded proguard rule to keep the GoogleUtils.java file
They actually fixed the issue at release, 1.30.8 at the commit, 1.30.9 release just does the same fix in more android recommended way.
Although the final adopted version uses GoogleUtils.class.getResourceAsStream("google-api-client.properties") which is Java api and returns the InputStream to read the google-api-client.properties file. Since these stream may not work perfectly in some devices they still crash but with lesser frequency(as we still see the crashes with the fixed present in the release 1.30.9).
Created an issue to track this
So some background information. I am tasked with exploring writing cross platform native applications using Xamarin. Seems pretty basic so far and I'm liking what I'm reading. I have my Visual Studio 2015 Enterprise all set up and my remote mac configured on the network. I created a cross platform native app through the project creation wizard in Visual Studio. When I launch a debug session for the iOS app, it does start the target app in the simulator on the remote Mac. However, it never actually thinks it is running fully. It will hang at this output:
Launching 'PersonalProject.iOS' on 'iPhone 6 iOS 10.2'...
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/Xamarin.iOS.dll
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/System.dll
Thread started: #2
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/PersonalProject.iOS.exe
Loaded assembly: /Users/plm/Library/Developer/CoreSimulator/Devices/B5A038B6-056F-4E6C-A59C-29ABD8C04CD0/data/Containers/Bundle/Application/2A1B11FF-6C59-4A9B-9CE3-7B8446B1AD48/PersonalProject.iOS.app/System.Xml.dll
Eventually, it will fail with something along these lines:
The app has been terminated.
Launch failed. The app 'PersonalProject.iOS' could not be launched on 'iPhone 6 iOS 10.2'. Error: An error occurred while executing MTouch. Please check the logs for more details.
I've checked the log file in question and it contains nothing more than the same exact phrase.
If I try and put a simple line of Console writing on the action of pressing the button:
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
Button.AccessibilityIdentifier = "myButton";
Button.TouchUpInside += delegate {
var title = string.Format ("{0} clicks!", count++);
Button.SetTitle (title, UIControlState.Normal);
Console.WriteLine(string.Format("{0} clicks!"));
};
}
the debug session actually errors on this line 17 (UIApplication.Main) in the Main.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace PersonalProject.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main (string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
}
}
With Unhandled exception error:
Unhandled Exception:
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Error while resolving expression: One or more errors occurred.
If I don't have the console log it will launch the app, but still hanges at those Loaded assembly lines. At this point, I can't hit any breakpoints in my code. I tried adding a breakpoint in the shared code for the button click but it would never hit it, even though the action was being carried out by the simulator.
I'm completely at a loss for how to proceed. I haven't touched anything out of the box of the wizard creation. I was hoping I could at least see the starter project working.
Any help is appreciated.
You are using
Console.WriteLine(string.Format("{0} clicks!"));
The {0} is a placeholder for a value to output, but you never specify that value, that's why you are getting an error.
Use something like this instead:
Console.WriteLine(string.Format("{0} clicks!", count));
or in C#6 syntax:
Console.WriteLine($"{count} clicks!");
I'm having a confusing problem. I'm trying to make a Web cleint that uses WSDL.
I'm using C++ RAD Studio 10 Seattle, but the same problem occured in RAD Studio XE8(older version).
1.I create a Multi-Device Application, add one Edit component and one Button.
2.I create a WSDL Importer by changing the location of the WSDL file to : "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL" and leave all other setting to default.
3.On ButtonClick event of the button I write two lines of code :
_di_TempConvertSoap Converter = GetTempConvertSoap(true,
"http://www.w3schools.com/webservices/tempconvert.asmx?WSDL");
Edit1->Text = Converter->CelsiusToFahrenheit("32");
So after these three steps I have one unit, which is the main Unit with the Form and with the button event. And one file "tempconvert.cpp" that the WSDL Importer has generated. It quite actually just translates the WSDL code to a C++ one and defines the method to communicate with the server. In my case I have two methods : FahrenheitToCelsius() and CelsiusToFahrenheit(), in the example I use CelsiusToFahrenheit().
I compile it to 32-bit Windows platform, run it and when I click the button, the result "89.6" appears in the text of the Edit component. So this is working as expected.
But when I change the target platform to "Android" and use my mobile phone "Samsung GT-I8262" with Android 4.1.2 and run the project, it just stops and exits. I debugged the problem and it stops at the first command in "tempconvert.cpp" in RegTypes() method.
// ************************************************************************
//
// This routine registers the interfaces and types exposed by the WebService.
// ************************************************************************ //
static void RegTypes()
{
/* TempConvertSoap */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/%operationName%");
InvRegistry()->RegisterInvokeOptions(__delphirtti(TempConvertSoap), ioDocument);
/* TempConvertSoap.FahrenheitToCelsius */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "FahrenheitToCelsius", "",
"[ReturnName='FahrenheitToCelsiusResult']", IS_OPTN);
/* TempConvertSoap.CelsiusToFahrenheit */
InvRegistry()->RegisterMethodInfo(__delphirtti(TempConvertSoap), "CelsiusToFahrenheit", "",
"[ReturnName='CelsiusToFahrenheitResult']", IS_OPTN);
/* TempConvertHttpPost */
InvRegistry()->RegisterInterface(__delphirtti(TempConvertHttpPost), L"http://www.w3schools.com/webservices/", L"utf-8");
InvRegistry()->RegisterDefaultSOAPAction(__delphirtti(TempConvertHttpPost), L"");
}
#pragma startup RegTypes 32
Does someone have any idea why this might be happening? I tried on two other Samsung phones and it didn't work. The error that shuts the program down is "Segmentation fault(11)", and more precisely it stops at the following line of code in "System.pas" file :
u_strFromUTF8(PUChar(Dest), MaxDestChars, DestLen, MarshaledAString(Source), SourceBytes, ErrorConv);
Here is some info that I've found about the function:
u_strFromUTF8 - function that converts a UTF-8 string to UTF-16.
UCHAR is a Byte(in Delphi), so PUCHAR is a pointer to Byte.
I cannot se what could possibly go wrong with this function which apparently only converts a string.
So my question is why does the project work on Windows 32 bit version, but on Android it throws Segmentation fault(11)?
I hope I could find a solution for this problem. I will keep looking.
Thank you,
Zdravko Donev :)
UPDATE:
I disassembled the line:
InvRegistry()->RegisterInterface(__delphirtti(TempConvertSoap), L"http://www.w3schools.com/webservices/", L"utf-16");
to get :
TInvokableClassRegistry *Class = InvRegistry();
TTypeInfo *Info = __delphirtti(TempConvertSoap);
UnicodeString Namespace = "http://www.w3schools.com/webservices/";
UnicodeString WSDLEncoding = "utf-8";
Class->RegisterInterface(Info, Namespace, WSDLEncoding);
And I saw that the problem occurs when calling InvRegistry() function, but I still haven't found the problem as I cannot reach the source code of the function.
I found a solution.
I deleted the line
#pragma startup RegTypes 32
and called the method RegTypes() on my own when I create the form and it worked.
I want to access a android device from python to download some photos.
libmtp works from the CLI.
Than pymtp. It's been around for a while but it's designed for python 2 and i'm using python 3. Meanwhile fixed several minor issues but i'm stuck at an error from function get_filelisting
specially this section:
ret = []
next = files
while next:
ret.append(next.contents)
if (next(next.contents) is None):
break
next = next(next.contents)
The error is related to the "next".
That section looks strange to me, i've been coding in python for a while but i'm new to ctypes. Tried a lot of variants, they all failed. The "next" could be confusing with python buildin function so i renamed it to nextpointer and came to this code:
ret = []
nextpointer = files
while nextpointer:
ret.append(nextpointer.contents)
nextpointer = nextpointer.contents.next
It seems to work but did it work by accident ? does it have any design flaws ? Could anyone with experience on python ctypes confirm this a solution ? Any suggestion welcome.
From python2.7 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its next() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
from python3 documentation
next(iterator[, default])
Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is
exhausted, otherwise StopIteration is raised.
Notice that next() method was removed from python3 but the function still exists.
This is all I can say about the next function and .next()/__next__() methods.
I downloaded the pymtp module and get_filelisting() is slightly different from what you posted in your ported code, here it is:
ret = []
next = files
while next:
ret.append(next.contents)
if (next.contents.next == None):
break
next = next.contents.next
If none of this helped you (which probably didn't :D), the version of pymtp library that I am using is 0.0.6 download using pip.
On Linux systems I've used 'export GST_DEBUG=<#>' to debug problems with a program's use of GStreamer. I'm now working on Android and would like to do the same - see the GStreamer output included in the logcat output.
I have a Google Nexus 5 phone and I'm using the full_hammerhead_userdebug build. I've seen the following suggested:
Add the following in JNI_OnLoad:
setenv("GST_DEBUG", "*:5", 1);
setenv("GST_DEBUG_NO_COLOR", "1", 1);
Unfortunately I'm trying to debug a C library, so I would prefer to set something in the environment to enable the debug output. I tried to add the following lines to build.prop:
export GST_DEBUG=3
GST_DEBUG=3
log.redirect-stdio=true
That didn't work. Either I'm not enabling GST_DEBUG properly or I'm not redirecting it properly. Or I'm way off track and I should be doing something else. How can I enable GST_DEBUG with Android?
P.S. This question is similar to one, but that one didn't completely answer my question.
I ended up going in another direction to solve this problem. First I created my own GstLogFunction()
void gstAndroidLog(GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * function,
gint line,
GObject * object,
GstDebugMessage * message,
gpointer data)
{
if (level <= gst_debug_category_get_threshold (category))
{
__android_log_print(ANDROID_LOG_ERROR, "MY_APP", "%s,%s: %s",
file, function, gst_debug_message_get(message));
}
}
Then after gst_init() is called, I set up the log levels. If I want to see everything, I can set:
gst_debug_set_default_threshold( GST_LEVEL_DEBUG );
If I just want to see what is happening in a specific category, I can set:
gst_debug_set_threshold_for_name ("tcpclientsink", GST_LEVEL_LOG);
Then I just need to register the log function I created:
gst_debug_add_log_function(&gstAndroidLog, NULL);