我正在使用此代码将UUID转换为byte
public byte[] getIdAsByte(UUID uuid)
{
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试使用此功能重新创建UUID,
public UUID frombyte(byte[] b)
{
return UUID.nameUUIDFromBytes(b);
}
Run Code Online (Sandbox Code Playgroud)
它与UUID不同.前后转换randomUUID会返回两个不同的.
UUID u = UUID.randomUUID();
System.out.println(u.toString());
System.out.println(frombyte(getIdAsByte(u)).toString());
Run Code Online (Sandbox Code Playgroud)
打印:
1ae004cf-0f48-469f-8a94-01339afaec41
8b5d1a71-a4a0-3b46-bec3-13ab9ab12e8e
Run Code Online (Sandbox Code Playgroud) 首先,至少有2个帖子具有相同的问题,但这些解决方案不再起作用,至少在我的安装中不起作用.
我正在使用m2e与Eclipse和Android并尝试通过选择run as-> Android应用程序将该应用程序作为"Android应用程序"运行,但我总是收到此错误:
意外的顶级异常:java.lang.IllegalArgumentException:已添加:Lorg/hamcrest/BaseDescription;
...[2012-09-08 19:50:41 - net.mydomain.project-TRUNK]转换为Dalvik格式失败,错误1
这是工具R14部分中描述的问题.首先,这不能修复,因为我在ADT 20.0.3中遇到了这个问题.其次,我没有这些所谓的"_src"文件夹.我以前从未在Maven项目中见过它们,所以我不知道我现在该做什么.我连两次都没有链接库.至少我在项目中没有看到一些.任何想法如何让这个工作?
这是我的pom.xml,如果这有帮助:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.devgems.android</groupId>
<artifactId>kurzparkzonewien</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>kurzparkzonewien</name>
<properties>
<platform.version>1.6_r2</platform.version>
<android.sdk.path>/opt/android-sdk-linux</android.sdk.path>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<!-- Make sure this is below the android dependencies -->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.0-RC1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<plugins> …Run Code Online (Sandbox Code Playgroud)