mirah / pindah

Tools for building Android applications with Mirah
Apache License 2.0
228 stars 27 forks source link

Inference ErrorCannot find class R on compile #8

Closed xinuc closed 13 years ago

xinuc commented 13 years ago

I always get error like this when trying to compile a newly generated project:

compile:
Inference Error:
./org/xinuc/bukalapak/Start.mirah:6: Cannot find class R
    setContentView R.layout.main
                  ^^
rake aborted!
org.apache.tools.ant.BuildException: exec returned: 1

how can I fix this?

zapnap commented 13 years ago

Can you confirm that you're using the latest master? Or gem version?

xinuc commented 13 years ago

Yup, I'm using the latest master

xinuc commented 13 years ago

Here is what I do to reproduce the error:

$ git clone https://github.com/mirah/pindah.git
$ pindah/bin/pindah create org.xinuc.pindahtest pindahtest Start
$ cd pindahtest

edit Rakefile, replace

require "rubygems"
require "pindah"

with

require "../pindah/lib/pindah"

then run rake compile

technomancy commented 13 years ago

I just pushed a fix to git master that should take care of this; please reopen if it persists.

xinuc commented 13 years ago

Hi, I can confirm that this issue persists.

xinuc commented 13 years ago

Actually I can run rake debug and even rake install and I got my project installed (but can't be run). The error still persists.

zapnap commented 13 years ago

Can you try my fork (zapnap/pindah)?

xinuc commented 13 years ago

Nope, still no luck with your fork too.. :(

technomancy commented 13 years ago

Can anyone else confirm this? I can't repro. Maybe it has to do with the version of JRuby used? Upgrading to the latest RC may help.

zapnap commented 13 years ago

I was able to reproduce when running rake compile on current master. But I can't seem to replicate it on my own fork (slightly behind). Haven't yet had time to dig in any deeper though.

zapnap commented 13 years ago

using jruby 1.5.2 fwiw

xinuc commented 13 years ago

OK, I don't know what's going on... I've updated my jruby and mirah

$ ruby -v
jruby 1.6.0.RC2 (ruby 1.8.7 patchlevel 330) (2011-02-09 5434c72) (OpenJDK Client VM 1.6.0_20) [linux-i386-java]
$ mirahc -v
Mirah v0.0.6.dev

and run the exact steps I described above is there any problem with this steps?

I still got this error:

compile:
compiling Duby source in /home/xinuc/sandbox/pindahtest/src to /home/xinuc/sandbox/pindahtest/bin/classes
Inference Error:
/home/xinuc/sandbox/pindahtest/src/org/xinuc/pindahtest/Start.mirah:6: Cannot find class R
    setContentView R.layout.main
                  ^^

What else can be wrong?

technomancy commented 13 years ago

The new "pindah create" skeleton puts in an explicit package declaration since someone else realized this fixed the problem on their machine. Does it solve it for you as well?

xinuc commented 13 years ago

Actually no. Still the same error.

Do you have a clue why this happen in my env? A quick fix or a hack to fix this in my own laptop will be fine.

teemun commented 13 years ago

I ran into same issue. What helped, was the combination of an explicit package declaration and small modification to pindah build.xml.

Declared:

<path id="java.classpath">
    <pathelement location="${classpath}" />
</path>

And modified compile target:

<mirahc src="${src}" destdir="${classes}">  
    <classpath refid="java.classpath" />
</mirahc>
xinuc commented 13 years ago

@teemun thanks a lot... Finally I can compile it without any error...

@technomancy is there any chance this modification pulled into pindah?

xinuc commented 13 years ago

created pull request here https://github.com/mirah/pindah/pull/14 in case you're interested.

got 2 failed tests, but they're there before this modification.

mkilling commented 13 years ago

Still happens for me with current master.