Geobits
Geobits

Reputation: 22342

MoPub import problem, I know I'm just missing something stupid

So I decided to split my project(for lite/full versioning) today. I packed the main code into library project, added two new shell projects, and linked them together. All of that worked fine, and I can run either the lite or full version with no problem.

However, I'm having a problem with Mopub integration in the library project. I followed their little tutorial, which is very simple. My problem is the build order for packages within a project. As part of the install process(shown here), it creates a com.mopub.mobileads package in my project.

This is my first time having a problem with multiple packages within a project, but for some reason, Eclispe insists that my import:

import com.mopub.mobileads.MoPubView;

cannot be resolved, specifically the com.mopub part.

My only guess is that when I compile, it tries to compile my package first, and it's just not seeing the Mopub package yet. However, if that's the case, I cannot for the life of me figure out how to change the build order of individual packages. If I wanted to change the order of projects, I'd be set, since that's simple. Google hasn't been much help to me in this either.

I know I could just add the source files into my own package, fix their imports to match, and have th whole problem gone, but that's an ugly hack I'd rather avoid.

I know I'm just missing something stupid, but I'm just not seeing it.

The errors it gives are pointed at the import line, and every line that references MoPubView, which is exactly what you'd expect:

(error x 5)MoPubView cannot be resolved to a type   mainAct.java    
R.id.adView cannot be resolved  mainAct.java    
The import com.mopub cannot be resolved mainAct.java    

Upvotes: 6

Views: 1681

Answers (2)

ninehundreds
ninehundreds

Reputation: 1105

I encountered a similar issue when integrating the SDK with a project I'm working on in Android Studio (v0.8.9).

During the import I was unable to get com.mopub.mobileads.MoPubView to resolve. Turns out that when Mopub was imported as a module there were two problems:

  1. The MMSDK was not added as a dependency to the module.
  2. The mopub/src/main/java was not added as a source folder....only the gen folder.

After adding the dependency and additional source folder the implementation worked flawlessly. Hopefully this will help someone else out in the future.

Upvotes: 0

Nathan Shayefar
Nathan Shayefar

Reputation: 46

You can try to change how Eclipse responds to build path problems.

Access the project properties (right click your project => Properties or Command + I on mac) and select Java Compiler => Building from the left pane. On the right pane, Enable project specific settings and modify the options under Build path properties.

Assuming you don't actually have circular dependencies that need to be corrected, this should be sufficient.

Upvotes: 1

Related Questions