Too many method references - using AppEngine SDK in Android Studio - java

I'm using App Engine Endpoints for my Android application. The problem is that I get the following error after using Endpoints and adding another SDK:
trouble writing output: Too many method references: 116924; max is 65536.
You may try using --multi-dex option.
References by package:
23 com.google.appengine.api
1540 com.google.appengine.api.appidentity
22 com.google.appengine.api.backends
1421 com.google.appengine.api.blobstore
4 com.google.appengine.api.blobstore.proto2api
795 com.google.appengine.api.capabilities
352 com.google.appengine.api.channel
2374 com.google.appengine.api.datastore
5231 com.google.appengine.api.files
2950 com.google.appengine.api.images
174 com.google.appengine.api.log
722 com.google.appengine.api.mail
4 com.google.appengine.api.mail.proto2api
10 com.google.appengine.api.mail.stdimpl
3711 com.google.appengine.api.memcache
48 com.google.appengine.api.memcache.stdimpl
2178 com.google.appengine.api.modules
38 com.google.appengine.api.oauth
1497 com.google.appengine.api.prospectivesearch
8 com.google.appengine.api.prospectivesearch.proto2api
27 com.google.appengine.api.quota
14 com.google.appengine.api.rdbms
606 com.google.appengine.api.search
79 com.google.appengine.api.search.checkers
381 com.google.appengine.api.search.query
3724 com.google.appengine.api.socket
4 com.google.appengine.api.socket.proto2api
5443 com.google.appengine.api.taskqueue
4 com.google.appengine.api.taskqueue.proto2api
966 com.google.appengine.api.urlfetch
43 com.google.appengine.api.users
44 com.google.appengine.api.utils
1463 com.google.appengine.api.xmpp
4 com.google.appengine.api.xmpp.proto2api
5480 com.google.appengine.repackaged.com.google.appengine.api.search
1243 com.google.appengine.repackaged.com.google.common.base
7 com.google.appengine.repackaged.com.google.common.base.internal
8524 com.google.appengine.repackaged.com.google.common.collect
103 com.google.appengine.repackaged.com.google.common.escape
379 com.google.appengine.repackaged.com.google.common.flags
642 com.google.appengine.repackaged.com.google.common.hash
1 com.google.appengine.repackaged.com.google.common.html
578 com.google.appengine.repackaged.com.google.common.io
103 com.google.appengine.repackaged.com.google.common.math
39 com.google.appengine.repackaged.com.google.common.net
2 com.google.appengine.repackaged.com.google.common.parameterset
556 com.google.appengine.repackaged.com.google.common.primitives
36 com.google.appengine.repackaged.com.google.common.util
753 com.google.appengine.repackaged.com.google.common.util.concurrent
5 com.google.appengine.repackaged.com.google.common.xml
290 com.google.appengine.repackaged.com.google.io.base
177 com.google.appengine.repackaged.com.google.io.base.shell
1348 com.google.appengine.repackaged.com.google.io.protocol
1752 com.google.appengine.repackaged.com.google.io.protocol.proto
8 com.google.appengine.repackaged.com.google.io.protocol.proto.proto2api
4 com.google.appengine.repackaged.com.google.io.protocol.proto2
24 com.google.appengine.repackaged.com.google.net.base
25 com.google.appengine.repackaged.com.google.net.util.error
10402 com.google.appengine.repackaged.com.google.protobuf
191 com.google.appengine.repackaged.com.google.protobuf.bridge
12 com.google.appengine.repackaged.com.google.protobuf.contrib.descriptor_pool
51 com.google.appengine.repackaged.com.google.protobuf.contrib.htmlform
384 com.google.appengine.repackaged.com.google.protobuf.downgraded
1540 com.google.appengine.repackaged.com.google.protos.gdata.proto2api
8 com.google.appengine.repackaged.com.google.protos.proto2.bridge
3173 com.google.appengine.repackaged.com.google.storage.onestore.v3.proto2api
407 com.google.appengine.repackaged.org.antlr.runtime
368 com.google.appengine.repackaged.org.antlr.runtime.debug
43 com.google.appengine.repackaged.org.antlr.runtime.misc
422 com.google.appengine.repackaged.org.antlr.runtime.tree
2015 com.google.appengine.repackaged.org.joda.time
268 com.google.appengine.repackaged.org.joda.time.base
858 com.google.appengine.repackaged.org.joda.time.chrono
120 com.google.appengine.repackaged.org.joda.time.convert
533 com.google.appengine.repackaged.org.joda.time.field
540 com.google.appengine.repackaged.org.joda.time.format
178 com.google.appengine.repackaged.org.joda.time.tz
26 com.google.appengine.spi
1521 com.google.appengine.tools.appstats
39 com.google.appengine.tools.compilation
6283 com.google.apphosting.api
1971 com.google.apphosting.api.logservice
4 com.google.apphosting.api.logservice.proto2api
739 com.google.apphosting.api.proto2api
1688 com.google.apphosting.api.search
8 com.google.apphosting.base
207 com.google.apphosting.client.datastoreservice.app
102 com.google.apphosting.client.datastoreservice.app.mobile
1782 com.google.apphosting.client.datastoreservice.mobile
2343 com.google.apphosting.client.datastoreservice.proto
51 com.google.apphosting.client.serviceapp
6714 com.google.apphosting.datastore
705 com.google.apphosting.utils.remoteapi
59 com.google.apphosting.utils.servlet
785 com.google.cloud.sql.jdbc
532 com.google.cloud.sql.jdbc.internal
5 com.google.httputil
1 com.google.inject
1 com.google.inject.util
1 com.google.net.base
39 com.google.net.rpc
6 com.google.net.rpc.impl
6 com.google.net.rpc3.client
1 com.google.net.rpc3.impl
3 com.google.net.rpc3.impl.compatibility
1 com.google.net.rpc3.impl.server
5 com.google.net.rpc3.server
1 com.google.net.ssl
6099 com.google.protos.cloud.sql
10 com.google.storage.onestore
2287 com.google.storage.onestore.v3
3 default
5 it.unimi.dsi.fastutil.ints
6 java.awt.datatransfer
10 java.beans
226 java.io
438 java.lang
13 java.lang.ref
36 java.lang.reflect
28 java.math
73 java.net
68 java.nio
7 java.nio.channels
16 java.nio.charset
16 java.security
40 java.sql
34 java.text
520 java.util
129 java.util.concurrent
26 java.util.concurrent.atomic
37 java.util.concurrent.locks
14 java.util.logging
18 java.util.regex
5 java.util.zip
163 javax.activation
13 javax.annotation.processing
49 javax.cache
1 javax.lang.model
19 javax.lang.model.element
4 javax.lang.model.type
4 javax.lang.model.util
405 javax.mail
59 javax.mail.event
502 javax.mail.internet
108 javax.mail.search
45 javax.mail.util
1 javax.net.ssl
6 javax.servlet
26 javax.servlet.http
2 javax.tools
3 org.antlr.stringtemplate
23 org.apache.geronimo.mail.handlers
190 org.apache.geronimo.mail.util
4 org.xml.sax
2 org.xml.sax.helpers
6 sun.misc
As you can see, com.google.appengine is taking most of the method references. How can I limit it?

you hit the 65k method limit, there are a few options you can do.
in your gradle file you can specify minifyEnabled = true and it will cut down unused resources and code.
you can also use the SDK build tools 21.1.X that supports multi dex file creation using the dependency
compile 'com.android.support:multidex:1.0.0'
along with adding in multiDexEnabled true to your gradle. more information can be found here

Related

PMD Memory Leak

I have a serious memory leak when using pmd in eclipse on windows. I import a bunch of large maven projects. After m2e and compilation PMD starts up. It then eventually runs in about 8-10 eclipse job instances in parallel for the many (about 50) projects in the workspace. Then the process size grows endlessly until virtual memory on the machine is exhausted (at about 12 GB or so) and the PC completely freezes.
My memory config in eclipse.ini:
-Xms256m
-Xmx2G
-Xss2m
-Xverify:none
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XX:MaxMetaspaceSize=1G
The heap size limit here of 2 GB doesn't seem to have much effect. I suspect then that the allocated vm memory is not the java heap but classloader metaspace or from a native dll.
I've got 32 GB RAM on my machine. Using java 1.8.0_121.
Here's a vmmap snapshot shortly before the process gets dangerously large and I have to kill it:
I tried running jcmd PID GC.class_stats against the process, but I don't see the problem here, since total bytes is only ~1.4 GB:
1636:
Index Super InstBytes KlassBytes annotations CpAll MethodCount Bytecodes MethodAll ROAll RWAll Total ClassName
1 89 141004480 560 0 1296 7 149 2176 880 3464 4344 java.util.HashMap$Node
2 -1 131125856 480 0 0 0 0 0 24 584 608 [I
3 89 129135744 624 0 8712 94 4623 58024 12136 56304 68440 java.lang.String
4 -1 111470376 480 0 0 0 0 0 24 584 608 [B
5 -1 94462520 480 0 0 0 0 0 24 584 608 [C
6 -1 55019976 480 0 0 0 0 0 32 584 616 [Ljava.util.HashMap$Node;
7 -1 53828832 480 0 0 0 0 0 24 584 608 [Ljava.lang.Object;
8 89 51354560 504 0 9016 42 2757 23352 6976 26704 33680 java.net.URL
9 89 48028392 504 0 544 1 20 496 216 1520 1736 java.util.LinkedList$Node
10 28783 40910880 1000 0 6864 51 3951 35648 8664 35792 44456 java.util.HashMap
...snip...
48234 48225 0 608 0 288 2 10 288 160 1152 1312 sun.util.resources.en.CalendarData_en
48235 48225 0 608 0 360 2 27 304 200 1200 1400 sun.util.resources.en.CurrencyNames_en_US
48236 48225 0 608 0 288 2 10 288 160 1152 1312 sun.util.resources.en.LocaleNames_en
48237 48229 0 608 0 288 2 10 304 176 1152 1328 sun.util.resources.en.TimeZoneNames_en
48238 29013 0 520 0 272 2 5 592 160 1352 1512 sun.util.spi.CalendarProvider
48239 89 0 512 0 336 3 5 440 240 1184 1424 sun.util.spi.XmlPropertiesProvider
48240 89 0 560 0 440 5 16 760 488 1504 1992 sun.util.xml.PlatformXmlPropertiesProvider$EH
48241 89 0 528 0 1040 3 71 520 464 1840 2304 sun.util.xml.PlatformXmlPropertiesProvider$Resolver
48242 89 0 552 0 520 3 19 512 456 1392 1848 uescape.view.UnicodeEscapeView$1
48243 89 0 552 0 520 3 19 512 456 1392 1848 uescape.view.UnicodeEscapeView$2
1374367440 32457872 432408 90295960 502480 22001616 144854704 85034192 198366896 283401088 Total
485.0% 11.5% 0.2% 31.9% - 7.8% 51.1% 30.0% 70.0% 100.0%
Index Super InstBytes KlassBytes annotations CpAll MethodCount Bytecodes MethodAll ROAll RWAll Total ClassName
I don't have much experience profiling native processes on Windows. How can I determine what's endlessly allocating so much memory?
This is indeed a problem of the pmd-eclipse-plugin.
See https://github.com/pmd/pmd-eclipse-plugin/issues/52
The latest version 4.0.17.v20180801-1551 contains a fix.
It is available via the update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/

Anylogic: printing the outputs to excel

I have some datasets which I want to print to excel after each run of simulation.
Dataset name: Arrival1,
Excel file name: ExcelOutputs,
The code that I wrote: excelOutputs.writeDataSet(this.Arrival1, "Tabelle1", 1, 1);
Data in dataset:
0 0
300 15
480 24
700 35
900 45
1,180 59
1,360 68
1,520 76
1,740 87
1,980 99
2,180 109
2,460 123
2,700 135
2,900 145
3,340 167
3,500 175
Data I get in the excel sheet:
0 0
340 17
580 29
700 35
900 45
1200 60
1420 71
1600 80
1800 90
2020 101
2200 110
2340 117
2520 126
2620 131
2820 141
3000 150
3220 161
3360 168
Totally different numbers and I don't know where they come from. There is no other dataset with these numbers and the excel sheet is initially empty.
Can someone please help me! Thank you in advance

All Java Programs Crashing At Seemingly Random Points (Internal Error: Uncaught Exception)

I just updated to the latest version of Java today (Java 8 Update 101)
Ever since, every time I try to run any Java program, it crashes with the following error:
Error Message
Here's the content of the error:
Exception Name: JavaNativeException
Description: java.lang.NullPointerException
User Info: (null)
0 CoreFoundation 0x00007fffb962952b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffcdd01cad objc_exception_throw + 48
2 CoreFoundation 0x00007fffb9629479 -[NSException raise] + 9
3 JavaNativeFoundation 0x000000010e7266d8 JNFCallObjectMethod + 230
4 liblwawt.dylib 0x00000001101fa09e -[AWTView attributedSubstringForProposedRange:actualRange:] + 78
5 AppKit 0x00007fffb7b70604 -[NSTextInputContext(NSInputContext_WithCompletion) attributedSubstringForProposedRange:completionHandler:] + 105
6 AppKit 0x00007fffb7b6c6ec __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.625 + 91
7 AppKit 0x00007fffb7b66e9a -[NSTextInputContext tryHandleTSMEvent_attributedSubstringForProposedRange_withContext:dispatchCondition:dispatchWork:continuation:] + 92
8 AppKit 0x00007fffb7b6c616 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.620 + 450
9 AppKit 0x00007fffb73cd760 -[NSTextInputContext handleTSMEvent:completionHandler:] + 2549
10 AppKit 0x00007fffb73cccfd _NSTSMEventHandler + 319
11 HIToolbox 0x00007fffb8b190d5 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1708
12 HIToolbox 0x00007fffb8b18346 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 428
13 HIToolbox 0x00007fffb8b1818f SendEventToEventTargetWithOptions + 43
14 HIToolbox 0x00007fffb8b6ef86 SendTSMEvent_WithCompletionHandler + 408
15 HIToolbox 0x00007fffb8d22378 __SendTextInputEvent_WithCompletionHandler_block_invoke + 584
16 HIToolbox 0x00007fffb8d20689 SendTextInputEvent_WithCompletionHandler + 1154
17 HIToolbox 0x00007fffb8d91829 -[IMKInputSession _postEvent:completionHandler:] + 176
18 HIToolbox 0x00007fffb8da1485 -[IMKInputSession _copyUniCharsForRange:intoBuffer:ofLength:completionHandler:] + 530
19 HIToolbox 0x00007fffb8da1c0e -[IMKInputSession _coreAttributesFromRange:whichAttributes:completionHandler:] + 281
20 HIToolbox 0x00007fffb8da3bb0 -[IMKInputSession attributedSubstringFromRange:completionHandler:] + 186
21 HIToolbox 0x00007fffb8d943ab __61-[IMKInputSession imkxpc_attributedSubstringFromRange:reply:]_block_invoke + 530
22 CoreFoundation 0x00007fffb95bf3ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
23 CoreFoundation 0x00007fffb95a0424 __CFRunLoopDoBlocks + 356
24 CoreFoundation 0x00007fffb959ff66 __CFRunLoopRun + 1878
25 CoreFoundation 0x00007fffb959f5b4 CFRunLoopRunSpecific + 420
26 HIToolbox 0x00007fffb8b40f6c RunCurrentEventLoopInMode + 240
27 HIToolbox 0x00007fffb8b40da1 ReceiveNextEventCommon + 432
28 HIToolbox 0x00007fffb8b40bd6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
29 AppKit 0x00007fffb72375f5 _DPSNextEvent + 1093
30 AppKit 0x00007fffb79478eb -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1637
31 libosxapp.dylib 0x00000001102974e3 -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
32 AppKit 0x00007fffb722bfbd -[NSApplication run] + 926
33 libosxapp.dylib 0x0000000110297346 +[NSApplicationAWT runAWTLoopWithApp:] + 156
34 liblwawt.dylib 0x00000001101ed17d -[AWTStarter starter:] + 873
35 Foundation 0x00007fffbafebf2a __NSThreadPerformPerform + 326
36 CoreFoundation 0x00007fffb95bf551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
37 CoreFoundation 0x00007fffb95a06bd __CFRunLoopDoSources0 + 557
38 CoreFoundation 0x00007fffb959fbb6 __CFRunLoopRun + 934
39 CoreFoundation 0x00007fffb959f5b4 CFRunLoopRunSpecific + 420
40 java 0x000000010426e3b0 CreateExecutionEnvironment + 871
41 java 0x0000000104268b5c JLI_Launch + 1952
42 java 0x000000010426e70d main + 101
43 java 0x00000001042683b4 start + 52
I have heard of other users having a similar problem, some recently and some in 2014, 2010, 2006, etc.
I have tried uninstalling Java using cmd, as well as editing the environmental variable, though I just copied and pasted what I found on the internet and didn't really understand what I was doing:
Uninstall attempt/Environmental variable deletion attempt
I found instructions for a solution involving deleting the environmental variable that seemed promising, but I don't know how to do them for mac (all I could find was what I pasted in terminal, as seen in the picture above)
Seemingly promising instructions:
youtube.com/watch?v=JF_o8WNt3hs&feature=youtu.be
I can't use any of my java based programs now, including netbeans, without them crashing within a few clicks. They all seem to crash at random points, but it's possible that the points at which they crash all have to do with writing data to the drive.

Converting between different keycodes

Im currently working on a little game. before you have started the game I have a JFrame where you can setup your controllers. To do this im using the java built-in keylistener and it works great.
The problem occurs when im starting the game and the settings youve made doesn't work.
The game uses the lwjgl api and slick2d api and the keycode for when im checking for buttonpresses is different from the keycodes built in keylistener.
http://slick.ninjacave.com/javadoc/constant-values.html#org.newdawn.slick.Input.KEY_DOWN
A list of the keycodes slick uses. As you can see its different from this list
http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
is there a way to convert between these two?
I tried adding a constant but as you probably can see it wont work.
I appreciate every answer :)
I made a little solution now. Very simple maybe not the most effiecent but it works. Took some time though
I made a little list that i use for conversion. Could be some bugs but they are pretty easy so fix.
backspace 8 14
space 32 57
tab 9 15
enter 13 28
enter2 10 28
shift 16 42
ctrl 17 29
alt 18 56
pause 19 197
caps 20 58
escape 27 1
pgup 33 201
pgdo 34 209
end 35 207
home 36 199
left 37 203
up 38 200
right 39 205
down 40 208
insert2 155 210
delete 127 211
0 48 11
1 49 2
2 50 3
3 51 4
4 5 5
5 53 6
6 54 7
7 55 8
8 56 9
9 57 10
A 65 30
B 66 48
C 67 46
D 68 32
E 69 18
F 70 33
G 71 34
H 72 35
I 73 23
J 74 36
K 75 37
L 76 38
M 77 50
N 78 49
O 79 24
P 80 25
Q 81 16
R 82 19
S 83 31
T 84 20
U 85 22
V 86 47
W 87 17
X 88 45
Y 89 21
Z 90 44
Å 16777413 27
Ä 16777412 40
Ö 16777430 41
LWK 91 219
RWK 92 220
WINDOWS 524 219
SELECT 93 221
NUMPAD0 96 82
NUMPAD1 97 79
NUMPAD2 98 80
NUMPAD3 99 81
NUMPAD4 100 75
NUMPAD5 101 76
NUMPAD6 102 77
NUMPAD7 103 71
NUMPAD8 104 72
NUMPAD9 105 73
MULTIPLY 106 55
ADD 107 78
SUBTRACT 109 74
DECIMAL 110 83
DIVIDE 111 181
F1 112 59
F2 113 60
F3 114 61
F4 115 62
F5 116 63
F6 117 64
F7 118 65
F8 119 66
F9 120 67
F10 121 68
F11 122 87
F12 123 88
F13 124 100
F14 125 101
F15 126 102
NUMLOCK 144 69
SCROLLOCK2 145 70
SEMICOLON 186 39
EQUALSIGN 187 13
COMMA 188 51
COMMA2 44 51
DASH 189 12
PERIOD 190 52
PERIOD2 46 52
FORWARDSLASH 191 53
GRAVE 192 41
OPENBRACKET 219 26
BACKSLASH 220 43
CLOSEBRAKET 221 27
SINGLEQUOTE 222 40
§ 16777383 43
LESS 153 -1
DEADACUTE 129 -1
PLUS 521 13
MINUS 45 12
DeadDiaeresis 135 144

Obtaining EVDEV Event Code from raw bytes?

In a previous question , I asked how to interpret the event bytes from /dev/input/mice. Realizing now that /dev/input/mice does NOT give me the information I need, as I am using a touchscreen using the stmpe-ts driver. It is setup under EVDEV node /dev/input/event2, and using a personal program I built, I can obtain the neccessary bytes from this file. My only problem is translating that into Event Codes. Using evtest, I get this output:
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "stmpe-ts"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 2486
Min 0
Max 4095
Event code 1 (ABS_Y)
Value 1299
Min 0
Max 4095
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 255
Properties:
Testing ... (interrupt to exit)
I need those event codes, from the raw data obtained by reading directly from /dev/input/event2. This is as follows:
236 21 100 83 63 223 11 0 3 0 0 0 124 8 0 0 236 21 100 83 72 223 11 0 3 0 1 0 237 7
0 0 236 21 100 83 76 223 11 0 3 0 24 0 60 0 0 0 236 21 100 83 80 223 11 0 1 0 74
1 1 0 0 0 236 21 100 83 84 223 11 0 0 0 0 0 0 0 0 0 236 21 100 83 251 247 11 0 3 0 0 0
123 8 0 0 236 21 100 83 6 248 11 0 3 0 1 0 242 7 0 0 236 21 100 83 10 248 11 0 3 0 24
0 142 0 0 0 236 21 100 83 16 248 11 0 0 0 0 0 0 0 0 0 236 21 100 83 137 16 12 0 3 0 0
0 121 8 0 0 236 21 100 83 147 16 12 0 3 0 1 0 7 8 0 0 236 21 100 83 150 16 12 0 3 0 24
0 163 0 0 0 236 21 100 83 156 16 12 0 0 0 0 0 0 0 0 0
Is this even possible to do? If so, can someone help me out here? (Also, I've determined that a pattern occurs every 16 bytes or so, I've also determined that 236 and 237 are byte stating that the event is a touch event, 236 being touch without click, and 237 being touch with click)
The output of evdev nodes is a series of struct input_event, defined in linux/input.h.
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
So all you need to do is read into an array of those structs and then access each type/code as needed. Don't know how to do that in Java, but it's probably not that hard.
evtest is free software btw, so you can look at the code and see what it does.
Also look at libevdev, it's MIT license so you don't get 'tainted' by looking at it.
http://www.freedesktop.org/wiki/Software/libevdev/

Categories

Resources