Java Question Simple Library Compiler and @DependsOn

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I am using the Simple Library Compiler to build a wrapper for Amazon ads. I'm basing everything on the AdMob wrapper source code posted by Erel several years ago.

I need to reference an external jar. I see the @DependsOn attribute to include in the Java file. However when I add this to the Java file and compile in the Simple Library Compiler I receive the following error (the image below shows the Simple Library Compiler and output).

B4X:
Starting step: Compiling Java code.
javac 1.7.0_45
C:\Users\Barry\AndroidDev\Basic4Android\SimpleLibraryCompiler\AmazonAds\src\canalrun\b4a\amznwrapper\AMZNWrapper.java:29: error: cannot find symbol
@DependsOn(values={"amazon-ads"})
^
  symbol: class DependsOn
1 error

Error.

I have also attached my Java file. Below is the portion that generates the error.

B4X:
@Version(1.0f)
@ShortName("AmznAd")
@Events(values={"ReceiveAd", "FailedToReceiveAd (ErrorCode As String)"})
@ActivityObject
@DontInheritEvents
@Permissions(values={"android.permission.INTERNET", "android.permission.ACCESS_NETWORK_STATE"})
@DependsOn(values={"amazon-ads"})

public class AMZNWrapper extends ViewWrapper<AdLayout> {
    private AdLayout adView; // The ad view used to load and display the ad.
    private static final String LOG_TAG = "AMZNWrapper"; // Tag used to prefix all log messages

Thanks any help.
Barry.



upload_2014-2-20_16-35-9.png
 

Attachments

  • AMZNWrapper.java.txt
    3.4 KB · Views: 254

canalrun

Well-Known Member
Licensed User
Longtime User
is amazon-ads in your libs folder?

Thanks. Yep.

The purpose of the @DependsOn attribute within the .java source file is to generate a dependency referencing an external jar within the output XML file?

For example, in my case, the XML file output by the Simple Library Compiler should include the line:

B4X:
    <dependsOn>amazon-ads</dependsOn>

If I manually add this line to the XML file, everybody is happy. The external library is found and the wrapper I am developing works (sort of).

I'm either doing something wrong or the Simple Library Compiler doesn't support this attribute and it's giving me the "unknown symbol" error.

If I look in my current B4A AdLibs directory. Within the Admob.xml file I find the line:
<dependsOn>GoogleAdMobAdsSdk</dependsOn>

There is also the file GoogleAdMobAdsSdk.jar in this directory.

I don't have the source code for this version of the Admob wrapper, but I'm assuming it has the attribute statement @DependsOn(values={"GoogleAdMobAdsSdk"}) within it. With the "value" being the name of the jar file to reference.

In the examples included with the SLC, Flurry has the statement @DependsOn – so I'm confident the SLC supports this. I don't have all the included jars for the Flurry example, but if I comment out the lines of source code which depend on an external library, it doesn't choke with the "unknown symbol" error at the @DependsOn statement and adds <dependsOn> ... to the output xml.

Barry.
 
Last edited:

canalrun

Well-Known Member
Licensed User
Longtime User
Thanks. The import statement solved the problem.

I think you are right about using Eclipse. I was trying to sneak by with Notepad++. Eclipse has quite a few useful features for development.

I remember seeing a post that mentioned using SLC as a tool from within Eclipse. I will have to search for that.
 

giga

Well-Known Member
Licensed User
Longtime User

b4xscripter

Member
Licensed User
Longtime User
I think I have some problem understanding well the DependsOn statement....

In my case I pretend to compile this code to create my library. I need to import an external .jar file, as you can see in my code.

Can anyone tell me what should I put in the DependsOn?
Thank you a lot!!!!!


B4X:
package anywheresoftware.b4a.MongoDBClient;

import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.*;
import android.telephony.*; 


// MONGO

package app;

import com.mongodb.BasicDBObject;
import com.mongodb.BasicDBList;
import com.mongodb.BulkWriteOperation;
import com.mongodb.BulkWriteResult;
import com.mongodb.Cursor;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ParallelScanOptions;
import com.mongodb.ServerAddress;

// MONGO


import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;



@Permissions(values={"android.permission.INTERNET"})
@ShortName("MongoDBClient")
@DependsOn(values={"some java library "})
@ActivityObject


public class MongoDBClient {
 
public MongoDBClient()        
{
    
}
    

public String find(String miCollection,String query) throws UnknownHostException{
                MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
                DB db = mongoClient.getDB( "santander" );
                DBCollection coll = db.getCollection(miCollection);

                Object o = com.mongodb.util.JSON.parse(query);
                DBCursor cursor = coll.find((DBObject) o);
                System.out.println(cursor);
                return cursor.toArray().toString();
                            
                            
}
  public static void main(String[] args) throws Exception {
     
   MongoDBClient mc = new MongoDBClient();
   System.out.println(mc.find("t_input_hh","{}"));  
  }
 
}
 

b4xscripter

Member
Licensed User
Longtime User
well, I need to put only the .jar file...

B4X:
@DependsOn(values={"mongo-java-driver-2.13.1"})

Best regards
 
Top