这个问题与我之前关于stackoverflow的问题非常相似(http://stackoverflow.com/questions/14190692/how-to-debug-dalvikvm-rejecting-opcode)
Android 无法处理大量的局部变量,因此在方法之外定义它们是解决方案。在我之前的问题中,dalvikvm 拒绝了该方法。在这种情况下它是不同的,这里的代码:
ss = 78.0 / radiusearthkm + 1.0;
将 ss 设置为 1.0,而 radiuseathkm 在调试器的前几行中设置为 0.0,当它应该为 6378.135 时,ss 将 = 1.0122292801892716。然后,该错误会在接下来的几百次计算中传播,问题就出现了。
所以我改变了这个:
public static boolean sgp4init(
Gravconsttype whichconst, char opsmode, final int satn, final double epoch,
final double xbstar, final double xecco, final double xargpo,
final double xinclo, final double xmo, final double xno,
final double xnodeo, SGP4SatData satrec)
{
/* --------------------- local variables ------------------------ */
double ao, ainv, con42, cosio, sinio, cosio2, eccsq,
omeosq, posq, rp, rteosq,
cnodm, snodm, cosim, sinim, cosomm, sinomm, cc1sq,
cc2, cc3, coef, coef1, cosio4, day, dndt,
em, emsq, eeta, etasq, gam, argpm, nodem,
inclm, mm, nm, perige, pinvsq, psisq, qzms24,
rtemsq, s1, s2, s3, s4, s5, s6,
s7, sfour, ss1, ss2, ss3, ss4, ss5,
ss6, ss7, sz1, sz2, sz3, sz11, sz12,
sz13, sz21, sz22, sz23, sz31, sz32, sz33,
tc, temp, temp1, temp2, temp3, tsi, xpidot,
xhdot1, z1, z2, z3, z11, z12, z13,
z21, z22, z23, z31, z32, z33,
qzms2t, ss, j2, j3oj2, j4, x2o3, //r[3], v[3],
tumin, mu, radiusearthkm, xke, j3;
double[] r = new double[3];
double[] v = new double[3];
对此:
static double radiusearthkm, ao, ainv, con42, cosio, sinio, cosio2, eccsq,
omeosq, posq, rp, rteosq,
cnodm, snodm, cosim, sinim, cosomm, sinomm, cc1sq,
cc2, cc3, coef, coef1, cosio4, day, dndt,
em, emsq, eeta, etasq, gam, argpm, nodem,
inclm, mm, nm, perige, pinvsq, psisq, qzms24,
rtemsq, s1, s2, s3, s4, s5, s6,
s7, sfour, ss1, ss2, ss3, ss4, ss5,
ss6, ss7, sz1, sz2, sz3, sz11, sz12,
sz13, sz21, sz22, sz23, sz31, sz32, sz33,
tc, temp, temp1, temp2, temp3, tsi, xpidot,
xhdot1, z1, z2, z3, z11, z12, z13,
z21, z22, z23, z31, z32, z33,
qzms2t, ss, j2, j3oj2, j4, x2o3, //r[3], v[3],
tumin, mu, xke, j3;
public static boolean sgp4init(
SGP4unit_a.Gravconsttype whichconst, char opsmode, final int satn, final double epoch,
final double xbstar, final double xecco, final double xargpo,
final double xinclo, final double xmo, final double xno,
final double xnodeo, SGP4SatData satrec)
{
double[] r = new double[3];
double[] v = new double[3];
现在一切正常。