Mittwoch, 28. Oktober 2015

JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

At first glance you would expect an error like this:


JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING


quite simple: the JSON is incorrect.

But what if JSONLint even validates this as correct?


In this example, the code was produced by an Android App consuming a JSON interfaces produced by PHP.


And guess what?!


It was an UTF-8 encoding issue within the JSON content - a special character from a town name needed UTF-8 encoding.


This solves the issue and saved my Friday!



Why Maven won't recognize a local repository

Are you experiencing the issue, that your Maven won't recognize dependencies loaded from a local filesystem repository? e.g. in my case tapestry jars that were not yet publicly available were located locally inside a directory and configured as a local maven repository.
[WARNING] The POM for org.apache.tapestry:tapestry-webresources:jar:5.4-beta-38
is missing, no dependency information available
[WARNING] The POM for org.oscy.tapestry5:tapestry-common:jar:1.3 is missing, no
dependency information available
[WARNING] The POM for org.oscy.tapestry5:tapestry-common-web:jar:1.3 is missing,
 no dependency information available
[WARNING] The POM for org.oscy.tapestry5:tapestry-dao:jar:1.3 is missing, no dep
endency information available
[WARNING] The POM for org.oscy.tapestry5:tapestry-jpa-web:jar:1.3 is missing, no
 dependency information available
[WARNING] The POM for org.apache.tapestry:tapestry-upload:jar:5.4-beta-38 is mis
sing, no dependency information available
[WARNING] The POM for org.apache.tapestry:tapestry-beanvalidator:jar:5.4-beta-38
 is missing, no dependency information available
[WARNING] The POM for org.apache.tapestry:tapestry-test:jar:5.4-beta-38 is missi
ng, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.470 s
[INFO] Finished at: 2015-10-27T10:39:39+01:00
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------


So what's the problem? It can not be a firewall or proxy issue with a local directory...or can it?

In my particular case, for security reasons maven could not connect to the wild - it was only allowed to access our artifactory - configured as a mirror in the global maven settings within the Windows user directory inside  .m2/settings.xml. However, this even applies for the local file system!

The solution is simple - if you know it - or RTFM:

external:* = everything not on the localhost and not file based.

<mirrors>
<mirror>
<id>internal-repository</id>
<name>Maven Repository Manager running on repo.mycompany.com</name>
<url>http://ci.company:8080/artifactory/repo1</url>
<mirrorOf>external:*</mirrorOf>
</mirror>

Reload your global maven settings in Eclipse (or IntelliJ) - and try again (or use the command line maven build tool). It should work now!
 

Donnerstag, 15. Oktober 2015

Error:Access to the dex task is now impossible, starting with 1.4.0

When trying to add Newrelic to an Android app, the following error occured:

 

Error:Access to the dex task is now impossible, starting with 1.4.0
1.4.0 introduces a new Transform API allowing manipulation of the .class files.
See more information: http://tools.android.com/tech-docs/new-build-system/transform-api


On Stackoverflow, people were given advice, such as changing the gradle version:

Stackoverflow suggestion to change gradle version
However, this does not seem to be the right solution.

Montag, 12. Oktober 2015

Welcome to error.report

What is this site about?

Have you ever searched for an error message and only found the same question by others on the internet - but without a solution?

Then, this site might be for you....

To be honest, I will also use this site for myself. I found myself posting questions on the internet - and one year later I had the same problem again and found my own question again. This time I will remember the solution :-)

No matter whether a compile error, runtime error, general error message or a weird stacktrace - it is likely other people have had the same issue before and solved it already - or others might encounter the same issue and will be thankful to find the right solution and safe a lot of time.

If you have any issues yourself or any other suggestions, let us know....and leave a comment.

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/app/FragmentCompat23;

com.android.dex.DexException: Multiple dex files define Landroid/support/v13/app/FragmentCompat23;

UNEXPECTED TOP-LEVEL EXCEPTION:

    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)

Where did this error occur?

Latest Android Studio 1.4 using a gradle built.

What type of exception?

Runtime exception when starting an Android project.


What programming language and version?

Java 1.7

What dependencies?

The following dependencies are used.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile 'joda-time:joda-time:2.8.2'
    compile 'com.wefika:flowlayout:0.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
    compile 'com.makeramen:dragsortadapter:1.3.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'org.adw.library:discrete-seekbar:1.0.0'
    compile 'com.android.support:preference-v7:23.0.1'
    compile 'com.android.support:preference-v14:23.0.1'
    compile 'com.android.support:palette-v7:23.0.1'
    compile 'com.android.support:support-v13:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
}

THE SOLUTION

Other found issues on the web

On stackoverflow, in one case a similiar bug has this solution

The problem was in apkLib dependency and confuse msg from Gradle.

The one who asked this question could solve this problem this way:

this error appeared to me when I imported some libs that required Google Play services,

I just passed from:
compile 'com.google.android.gms:play-services:6.5.87'
to:
compile ('com.google.android.gms:play-services:6.5.87') {
    exclude module: 'support-v4'
}
Now it builds ok



http://stackoverflow.com/questions/25384166/multiple-dex-files-define-landroid-support-v4-accessibilityservice-accessibility

My issue

Luckily my issue could be solved using a smiliar approach, just with the latest Google Play Services GCM


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile ('com.google.android.gms:play-services-gcm:8.1.0') {
        exclude module: 'support-v4'
    }
    compile 'joda-time:joda-time:2.8.2'
    compile 'com.wefika:flowlayout:0.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
    compile 'com.makeramen:dragsortadapter:1.3.0'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'org.adw.library:discrete-seekbar:1.0.0'
    compile 'com.android.support:preference-v7:23.0.1'
    compile 'com.android.support:preference-v14:23.0.1'
    compile 'com.android.support:palette-v7:23.0.1'
    compile 'com.android.support:support-v13:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
}